All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ovirt.engine.api.builders.V4VmBuilder Maven / Gradle / Ivy

There is a newer version: 1.3.10
Show newest version
/*
Copyright (c) 2015 Red Hat, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package org.ovirt.engine.api.builders;

import java.lang.Boolean;
import java.lang.String;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.ovirt.engine.api.containers.V4VmContainer;
import org.ovirt.engine.api.types.V4Cpu;
import org.ovirt.engine.api.types.V4Disk;
import org.ovirt.engine.api.types.V4Vm;

public class V4VmBuilder {
    private V4Cpu cpu;
    private Date creationTime;
    private Boolean deleteProtected;
    private List disks;
    private String fqdn;
    private String id;
    private BigInteger memory;
    private String name;
    private Boolean runOnce;
    
    public V4VmBuilder setCpu(V4Cpu newCpu) {
        cpu = newCpu;
        return this;
    }
    
    public V4VmBuilder setCpu(V4CpuBuilder newCpu) {
        if (newCpu == null) {
            cpu = null;
        }
        else {
            cpu = newCpu.build();
        }
        return this;
    }
    
    
    public V4VmBuilder setCreationTime(Date newCreationTime) {
        creationTime = newCreationTime;
        return this;
    }
    
    
    public V4VmBuilder setDeleteProtected(boolean newDeleteProtected) {
        deleteProtected = Boolean.valueOf(newDeleteProtected);
        return this;
    }
    
    public V4VmBuilder setDeleteProtected(Boolean newDeleteProtected) {
        deleteProtected = newDeleteProtected;
        return this;
    }
    
    
    public V4VmBuilder setDisks(List newDisks) {
        if (newDisks == null || newDisks.isEmpty()) {
            disks = null;
        }
        else {
            disks = new ArrayList<>(newDisks);
        }
        return this;
    }
    
    public V4VmBuilder setDisks(V4Disk... newDisks) {
        if (newDisks == null || newDisks.length == 0) {
            disks = null;
        }
        else {
            disks = Arrays.asList(newDisks);
        }
        return this;
    }
    
    public V4VmBuilder addDisks(List newDisks) {
        if (newDisks != null) {
            if (disks == null) {
                disks = new ArrayList<>(newDisks);
            }
            else {
                disks.addAll(newDisks);
            }
        }
        return this;
    }
    
    public V4VmBuilder addDisks(V4Disk... newDisks) {
        if (newDisks != null) {
            Collections.addAll(disks, newDisks);
        }
        return this;
    }
    
    
    public V4VmBuilder setFqdn(String newFqdn) {
        fqdn = newFqdn;
        return this;
    }
    
    
    public V4VmBuilder setId(String newId) {
        id = newId;
        return this;
    }
    
    
    public V4VmBuilder setMemory(int newMemory) {
        memory = BigInteger.valueOf((long) newMemory);
        return this;
    }
    
    public V4VmBuilder setMemory(Integer newMemory) {
        if (newMemory == null) {
            memory = null;
        }
        else {
            memory = BigInteger.valueOf(newMemory.longValue());
        }
        return this;
    }
    
    public V4VmBuilder setMemory(long newMemory) {
        memory = BigInteger.valueOf(newMemory);
        return this;
    }
    
    public V4VmBuilder setMemory(Long newMemory) {
        if (newMemory == null) {
            memory = null;
        }
        else {
            memory = BigInteger.valueOf(newMemory.longValue());
        }
        return this;
    }
    
    public V4VmBuilder setMemory(BigInteger newMemory) {
        memory = newMemory;
        return this;
    }
    
    
    public V4VmBuilder setName(String newName) {
        name = newName;
        return this;
    }
    
    
    public V4VmBuilder setRunOnce(boolean newRunOnce) {
        runOnce = Boolean.valueOf(newRunOnce);
        return this;
    }
    
    public V4VmBuilder setRunOnce(Boolean newRunOnce) {
        runOnce = newRunOnce;
        return this;
    }
    
    
    public V4Vm build() {
        V4VmContainer container = new V4VmContainer();
        container.setCpu(cpu);
        container.setCreationTime(creationTime);
        container.setDeleteProtected(deleteProtected);
        container.setDisks(disks);
        container.setFqdn(fqdn);
        container.setId(id);
        container.setMemory(memory);
        container.setName(name);
        container.setRunOnce(runOnce);
        return container;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy