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

com.anaptecs.jeaf.junit.generics.AndOneMorePOJOBase Maven / Gradle / Ivy

There is a newer version: 1.24.1
Show newest version
/*
 * anaptecs GmbH, Ricarda-Huch-Str. 71, 72760 Reutlingen, Germany
 *
 * Copyright 2004 - 2019. All rights reserved.
 */
package com.anaptecs.jeaf.junit.generics;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

import javax.annotation.Generated;
import javax.validation.ConstraintViolationException;

import com.anaptecs.jeaf.tools.api.validation.ValidationTools;
import com.anaptecs.jeaf.xfun.api.checks.Check;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;

@Generated("com.anaptecs.jeaf.generator.JEAFGenerator")
@SuppressWarnings("JEAF_SUPPRESS_WARNINGS")
@JsonIgnoreProperties(ignoreUnknown = true)
public abstract class AndOneMorePOJOBase {
  /**
   * Constant for the name of attribute "genericProperty".
   */
  public static final String GENERICPROPERTY = "genericProperty";

  /**
   * Constant for the name of attribute "genericResponses".
   */
  public static final String GENERICRESPONSES = "genericResponses";

  private GenericResponsePOJO genericProperty;

  @JsonSetter(nulls = Nulls.SKIP)
  private Set> genericResponses;

  /**
   * Default constructor is only intended to be used for deserialization by tools like Jackson for JSON. For "normal"
   * object creation builder should be used instead.
   */
  protected AndOneMorePOJOBase( ) {
    genericResponses = new HashSet>();
  }

  /**
   * Initialize object using the passed builder.
   *
   * @param pBuilder Builder that should be used to initialize this object. The parameter must not be null.
   */
  protected AndOneMorePOJOBase( BuilderBase pBuilder ) {
    // Ensure that builder is not null.
    Check.checkInvalidParameterNull(pBuilder, "pBuilder");
    // Read attribute values from builder.
    genericProperty = pBuilder.genericProperty;
    if (pBuilder.genericResponses != null) {
      genericResponses = pBuilder.genericResponses;
    }
    else {
      genericResponses = new HashSet>();
    }
  }

  /**
   * Class implements builder to create a new instance of class AndOneMorePOJO. As the class has read only attributes or
   * associations instances can not be created directly. Instead this builder class has to be used.
   */
  public static abstract class BuilderBase {
    private GenericResponsePOJO genericProperty;

    private Set> genericResponses;

    /**
     * Use {@link AndOneMorePOJO.builder()} instead of protected constructor to create new builder.
     */
    protected BuilderBase( ) {
    }

    /**
     * Use {@link AndOneMorePOJO.builder(AndOneMorePOJO)} instead of protected constructor to create new builder.
     */
    protected BuilderBase( AndOneMorePOJOBase pObject ) {
      if (pObject != null) {
        // Read attribute values from passed object.
        this.setGenericProperty(pObject.genericProperty);
        this.setGenericResponses(pObject.genericResponses);
      }
    }

    /**
     * Method sets attribute {@link #genericProperty}.
* * @param pGenericProperty Value to which {@link #genericProperty} should be set. * @return {@link BuilderBase} Instance of this builder to support chaining setters. Method never returns null. */ public BuilderBase setGenericProperty( GenericResponsePOJO pGenericProperty ) { // Assign value to attribute genericProperty = pGenericProperty; return this; } /** * Method sets association {@link #genericResponses}.
* * @param pGenericResponses Collection to which {@link #genericResponses} should be set. * @return {@link BuilderBase} Instance of this builder to support chaining setters. Method never returns null. */ public BuilderBase setGenericResponses( Set> pGenericResponses ) { // To ensure immutability we have to copy the content of the passed collection. if (pGenericResponses != null) { genericResponses = new HashSet>(pGenericResponses); } else { genericResponses = null; } return this; } /** * Method adds the passed objects to association {@link #genericResponses}.
* * @param pGenericResponses Array of objects that should be added to {@link #genericResponses}. The parameter may be * null. * @return {@link BuilderBase} Instance of this builder to support chaining. Method never returns null. */ public BuilderBase addToGenericResponses( GenericResponsePOJO... pGenericResponses ) { if (pGenericResponses != null) { if (genericResponses == null) { genericResponses = new HashSet>(); } genericResponses.addAll(Arrays.asList(pGenericResponses)); } return this; } /** * Method creates a new instance of class AndOneMorePOJO. The object will be initialized with the values of the * builder. * * @return AndOneMorePOJO Created object. The method never returns null. */ public AndOneMorePOJO build( ) { return new AndOneMorePOJO(this); } /** * Method creates a new validated instance of class AndOneMorePOJO. The object will be initialized with the values * of the builder and validated afterwards. * * @return AndOneMorePOJO Created and validated object. The method never returns null. * @throws ConstraintViolationException in case that one or more validations for the created object failed. */ public AndOneMorePOJO buildValidated( ) throws ConstraintViolationException { AndOneMorePOJO lPOJO = this.build(); ValidationTools.getValidationTools().enforceObjectValidation(lPOJO); return lPOJO; } } /** * Method returns attribute {@link #genericProperty}.
* * @return {@link GenericResponsePOJO} Value to which {@link #genericProperty} is set. */ public GenericResponsePOJO getGenericProperty( ) { return genericProperty; } /** * Method sets attribute {@link #genericProperty}.
* * @param pGenericProperty Value to which {@link #genericProperty} should be set. */ public void setGenericProperty( GenericResponsePOJO pGenericProperty ) { // Assign value to attribute genericProperty = pGenericProperty; } /** * Method returns association {@link #genericResponses}.
* * @return {@link Set>} Value to which {@link #genericResponses} is set. The * method never returns null and the returned collection is unmodifiable. */ public Set> getGenericResponses( ) { // Return all DoSomethingResponse objects as unmodifiable collection. return Collections.unmodifiableSet(genericResponses); } /** * Method adds the passed object to {@link #genericResponses}. * * @param pGenericResponses Object that should be added to {@link #genericResponses}. The parameter must not be null. */ public void addToGenericResponses( GenericResponsePOJO pGenericResponses ) { // Check parameter "pGenericResponses" for invalid value null. Check.checkInvalidParameterNull(pGenericResponses, "pGenericResponses"); // Add passed object to collection of associated DoSomethingResponse objects. genericResponses.add(pGenericResponses); } /** * Method adds all passed objects to {@link #genericResponses}. * * @param pGenericResponses Collection with all objects that should be added to {@link #genericResponses}. The * parameter must not be null. */ public void addToGenericResponses( Collection> pGenericResponses ) { // Check parameter "pGenericResponses" for invalid value null. Check.checkInvalidParameterNull(pGenericResponses, "pGenericResponses"); // Add all passed objects. for (GenericResponsePOJO lNextObject : pGenericResponses) { this.addToGenericResponses(lNextObject); } } /** * Method removes the passed object from {@link #genericResponses}.
* * @param pGenericResponses Object that should be removed from {@link #genericResponses}. The parameter must not be * null. */ public void removeFromGenericResponses( GenericResponsePOJO pGenericResponses ) { // Check parameter for invalid value null. Check.checkInvalidParameterNull(pGenericResponses, "pGenericResponses"); // Remove passed object from collection of associated DoSomethingResponse objects. genericResponses.remove(pGenericResponses); } /** * Method removes all objects from {@link #genericResponses}. */ public void clearGenericResponses( ) { // Remove all objects from association "genericResponses". genericResponses.clear(); } /** * Convenience method to create new instance of class AndOneMorePOJO. * * * @param pGenericProperty Value to which {@link #genericProperty} should be set. * * @return {@link com.anaptecs.jeaf.junit.generics.AndOneMorePOJO} */ public static AndOneMorePOJO of( GenericResponsePOJO pGenericProperty ) { AndOneMorePOJO.Builder lBuilder = AndOneMorePOJO.builder(); lBuilder.setGenericProperty(pGenericProperty); return lBuilder.build(); } /** * @return {@link GenericResponsePOJO} */ public abstract GenericResponsePOJO getEnumTemplate( ); @Override public int hashCode( ) { final int lPrime = 31; int lResult = 1; lResult = lPrime * lResult + Objects.hashCode(genericProperty); lResult = lPrime * lResult + Objects.hashCode(genericResponses); return lResult; } @Override public boolean equals( Object pObject ) { boolean lEquals; if (this == pObject) { lEquals = true; } else if (pObject == null) { lEquals = false; } else if (this.getClass() != pObject.getClass()) { lEquals = false; } else { AndOneMorePOJOBase lOther = (AndOneMorePOJOBase) pObject; lEquals = Objects.equals(genericProperty, lOther.genericProperty) && Objects.equals(genericResponses, lOther.genericResponses); } return lEquals; } /** * Method returns a StringBuilder that can be used to create a String representation of this object. The returned * StringBuilder also takes care about attributes of super classes. * * @return {@link StringBuilder} StringBuilder representing this object. The method never returns null. */ public StringBuilder toStringBuilder( String pIndent ) { StringBuilder lBuilder = new StringBuilder(); lBuilder.append(pIndent); lBuilder.append(this.getClass().getName()); lBuilder.append(System.lineSeparator()); lBuilder.append(pIndent); lBuilder.append("genericProperty: "); lBuilder.append(genericProperty); lBuilder.append(System.lineSeparator()); lBuilder.append(pIndent); lBuilder.append("genericResponses: "); if (genericResponses != null) { lBuilder.append(genericResponses.size()); lBuilder.append(" element(s)"); } else { lBuilder.append(" null"); } lBuilder.append(System.lineSeparator()); if (genericResponses != null) { for (GenericResponsePOJO lNext : genericResponses) { lBuilder.append(pIndent + " "); lBuilder.append(lNext.toString()); lBuilder.append(System.lineSeparator()); } } return lBuilder; } /** * Method creates a new String with the values of all attributes of this class. All references to other objects will * be ignored. * * @return {@link String} String representation of this object. The method never returns null. */ @Override public String toString( ) { return this.toStringBuilder("").toString(); } /** * Method creates a new builder and initializes it with the data of this object. * * @return {@link Builder} New builder that can be used to create new AndOneMorePOJO objects. The method never returns * null. */ public AndOneMorePOJO.Builder toBuilder( ) { return new AndOneMorePOJO.Builder((AndOneMorePOJO) this); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy