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

io.sundr.examples.arrays.PersonFluentImpl Maven / Gradle / Ivy

package io.sundr.examples.arrays;

import java.lang.Integer;
import io.sundr.builder.BaseFluent;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.String;
import java.lang.Boolean;

public class PersonFluentImpl> extends BaseFluent implements PersonFluent{

    private String firstName;
    private String lastName;
    private List numbers;

    public PersonFluentImpl(){
    }
    public PersonFluentImpl(Person instance){
            this.withFirstName(instance.getFirstName()); 
            this.withLastName(instance.getLastName()); 
            this.withNumbers(instance.getNumbers()); 
    }

    public String getFirstName(){
            return this.firstName;
    }

    public A withFirstName(String firstName){
            this.firstName=firstName; return (A) this;
    }

    public Boolean hasFirstName(){
            return this.firstName != null;
    }

    public String getLastName(){
            return this.lastName;
    }

    public A withLastName(String lastName){
            this.lastName=lastName; return (A) this;
    }

    public Boolean hasLastName(){
            return this.lastName != null;
    }

    public A withNumbers(int... numbers){
            if (this.numbers != null) {this.numbers.clear();}
            if (numbers != null) {for (int item :numbers){ this.addToNumbers(item);}} return (A) this;
    }

    public int[] getNumbers(){
            //This needs to work with primitives, so we use arrays.
int size = numbers != null ? numbers.size() : 0;
int[] result = new int[size];
if (size == 0) {
   return result;
}
int index = 0;
for (int item : numbers) {
    result[index++]=item;
}
return result;

    }

    public A addToNumbers(int index,Integer item){
            if (this.numbers == null) {this.numbers = null;}
            this.numbers.add(index, item);
            return (A)this;
    }

    public A setToNumbers(int index,Integer item){
            if (this.numbers == null) {this.numbers = null;}
            this.numbers.set(index, item); return (A)this;
    }

    public A addToNumbers(Integer... items){
            if (this.numbers == null) {this.numbers = null;}
            for (Integer item : items) {this.numbers.add(item);} return (A)this;
    }

    public A addAllToNumbers(Collection items){
            if (this.numbers == null) {this.numbers = null;}
            for (Integer item : items) {this.numbers.add(item);} return (A)this;
    }

    public A removeFromNumbers(Integer... items){
            for (Integer item : items) {if (this.numbers!= null){ this.numbers.remove(item);}} return (A)this;
    }

    public A removeAllFromNumbers(Collection items){
            for (Integer item : items) {if (this.numbers!= null){ this.numbers.remove(item);}} return (A)this;
    }

    public Boolean hasNumbers(){
            return numbers != null && !numbers.isEmpty();
    }

    public boolean equals(Object o){
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            PersonFluentImpl that = (PersonFluentImpl) o;
            if (firstName != null ? !firstName.equals(that.firstName) :that.firstName != null) return false;
            if (lastName != null ? !lastName.equals(that.lastName) :that.lastName != null) return false;
            if (numbers != null ? !numbers.equals(that.numbers) :that.numbers != null) return false;
            return true;
    }




}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy