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.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;
import org.ovirt.engine.api.types.V4VmType;

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;
    private V4VmType type;
    
    public V4VmBuilder cpu(V4Cpu newCpu) {
        cpu = newCpu;
        return this;
    }
    
    public V4VmBuilder cpu(V4CpuBuilder newCpu) {
        if (newCpu == null) {
            cpu = null;
        }
        else {
            cpu = newCpu.build();
        }
        return this;
    }
    
    
    public V4VmBuilder creationTime(Date newCreationTime) {
        if (newCreationTime == null) {
            creationTime = null;
        }
        else {
            creationTime = new Date(newCreationTime.getTime());
        }
        return this;
    }
    
    
    public V4VmBuilder deleteProtected(boolean newDeleteProtected) {
        deleteProtected = Boolean.valueOf(newDeleteProtected);
        return this;
    }
    
    public V4VmBuilder deleteProtected(Boolean newDeleteProtected) {
        deleteProtected = newDeleteProtected;
        return this;
    }
    
    
    public V4VmBuilder disks(List newDisks) {
        if (newDisks != null) {
            if (disks == null) {
                disks = new ArrayList<>(newDisks);
            }
            else {
                disks.addAll(newDisks);
            }
        }
        return this;
    }
    
    public V4VmBuilder disks(V4Disk... newDisks) {
        if (newDisks != null) {
            if (disks == null) {
                disks = new ArrayList<>(newDisks.length);
            }
            Collections.addAll(disks, newDisks);
        }
        return this;
    }
    
    public V4VmBuilder disks(V4DiskBuilder... newDisks) {
        if (newDisks != null) {
            if (disks == null) {
                disks = new ArrayList<>(newDisks.length);
            }
            for (V4DiskBuilder builder : newDisks) {
                disks.add(builder.build());
            }
        }
        return this;
    }
    
    
    public V4VmBuilder fqdn(String newFqdn) {
        fqdn = newFqdn;
        return this;
    }
    
    
    public V4VmBuilder id(String newId) {
        id = newId;
        return this;
    }
    
    
    public V4VmBuilder memory(int newMemory) {
        memory = BigInteger.valueOf((long) newMemory);
        return this;
    }
    
    public V4VmBuilder memory(Integer newMemory) {
        if (newMemory == null) {
            memory = null;
        }
        else {
            memory = BigInteger.valueOf(newMemory.longValue());
        }
        return this;
    }
    
    public V4VmBuilder memory(long newMemory) {
        memory = BigInteger.valueOf(newMemory);
        return this;
    }
    
    public V4VmBuilder memory(Long newMemory) {
        if (newMemory == null) {
            memory = null;
        }
        else {
            memory = BigInteger.valueOf(newMemory.longValue());
        }
        return this;
    }
    
    public V4VmBuilder memory(BigInteger newMemory) {
        memory = newMemory;
        return this;
    }
    
    
    public V4VmBuilder name(String newName) {
        name = newName;
        return this;
    }
    
    
    public V4VmBuilder runOnce(boolean newRunOnce) {
        runOnce = Boolean.valueOf(newRunOnce);
        return this;
    }
    
    public V4VmBuilder runOnce(Boolean newRunOnce) {
        runOnce = newRunOnce;
        return this;
    }
    
    
    public V4VmBuilder type(V4VmType newType) {
        type = newType;
        return this;
    }
    
    
    public V4Vm build() {
        V4VmContainer container = new V4VmContainer();
        container.cpu(cpu);
        container.creationTime(creationTime);
        container.deleteProtected(deleteProtected);
        container.disks(disks);
        container.fqdn(fqdn);
        container.id(id);
        container.memory(memory);
        container.name(name);
        container.runOnce(runOnce);
        container.type(type);
        return container;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy