Example usage for org.apache.commons.lang.builder ToStringStyle MULTI_LINE_STYLE

List of usage examples for org.apache.commons.lang.builder ToStringStyle MULTI_LINE_STYLE

Introduction

In this page you can find the example usage for org.apache.commons.lang.builder ToStringStyle MULTI_LINE_STYLE.

Prototype

ToStringStyle MULTI_LINE_STYLE

To view the source code for org.apache.commons.lang.builder ToStringStyle MULTI_LINE_STYLE.

Click Source Link

Document

The multi line toString style.

Usage

From source file:com.likethecolor.alchemy.api.entity.QuotationAlchemyEntityTest.java

@Test
public void testToString_Formatted() {
    final ToStringStyle style = ToStringStyle.MULTI_LINE_STYLE;
    final String quotation = "They should have run the complete, original version,? Finley told ...";
    final Double sentimentScore = -0.233275D;
    final boolean sentimentIsMixed = true;
    final SentimentAlchemyEntity.TYPE sentimentType = SentimentAlchemyEntity.TYPE.NEGATIVE;
    final SentimentAlchemyEntity sentiment = new SentimentAlchemyEntity(sentimentIsMixed, sentimentScore,
            sentimentType.toString());/*from w  ww .  ja va  2 s  .c  o m*/

    final QuotationAlchemyEntity entity = new QuotationAlchemyEntity(quotation, sentiment);

    final String expectedString = new ToStringBuilder(entity, style).append("quotation", quotation)
            .append("sentiment", sentiment).toString();

    final String actualString = entity.toString(style);

    assertEquals(expectedString, actualString);
}

From source file:com.sccl.attech.modules.sys.entity.Menu.java

/**
 * @see java.lang.Object#toString()/* w w  w .  j a  v a2 s  .c o  m*/
 */
public String toString() {
    return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("name", this.name)
            .append("href", this.href).append("isMobile", this.isMobile).toString();
}

From source file:com.likethecolor.alchemy.api.entity.AlchemyActionTest.java

@Test
public void testToString_Formatted() {
    final String lematized = "have be find";
    final String text = "has been found";
    final boolean isNegated = true;
    final String verbText = "find";
    final AlchemyVerb.TENSE tense = AlchemyVerb.TENSE.PAST;
    final ToStringStyle style = ToStringStyle.MULTI_LINE_STYLE;

    final AlchemyVerb verbEntity = new AlchemyVerb();

    verbEntity.setIsNegated(isNegated);/*from   w  w w  .  j  a va  2 s.  c  o m*/
    verbEntity.setTense(tense);
    verbEntity.setText(verbText);

    final AlchemyAction entity = new AlchemyAction();
    entity.setLematized(lematized);
    entity.setText(text);
    entity.setVerb(verbEntity);

    final String expectedString = new ToStringBuilder(entity, style).append("lematized", lematized)
            .append("text", text).append("verb", verbEntity.toString(style)).toString();

    final String actualString = entity.toString(style);

    assertEquals(expectedString, actualString);
}

From source file:com.google.code.mymon3y.model.Usuario.java

@Override
public String toString() {
    return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", id).append("login", login)
            .append("senha", senha).append("categorias", categorias).toString();
}

From source file:net.sf.json.JSONDynaBean.java

/**
 * DOCUMENT ME!/*from  w w  w.  ja  v a  2 s. c om*/
 *
 * @return DOCUMENT ME!
 */
public String toString() {
    return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append(dynaValues).toString();
}

From source file:com.xtructure.xevolution.genetics.impl.UTestAbstractPopulation.java

public void refreshStatsBehavesAsExpected() {
    DummyPopulation population = new DummyPopulation(0);
    Map<XValId<?>, Genome<?>> highGenomes = new HashMap<XValId<?>, Genome<?>>();
    Map<XValId<?>, Genome<?>> lowGenomes = new HashMap<XValId<?>, Genome<?>>();
    Map<XValId<?>, Double> averageMeasures = new HashMap<XValId<?>, Double>();
    ValueMap attributes = new ValueMap();
    attributes.set(Population.AGE_ATTRIBUTE_ID, 0l);
    attributes.set(Population.AGE_LI_ATTRIBUTE_ID, 0l);
    attributes.set(Population.GENOME_NUM_ATTRIBUTE_ID, 0);
    population.refreshStats();// w w w .  j a v a 2  s .c o m
    String expected = new ToStringBuilder(population, ToStringStyle.MULTI_LINE_STYLE)//
            .append("id", population.getId())//
            .append("size", 0)//
            .append("attributes", attributes)//
            .append("highGenomes", mapToString(highGenomes))//
            .append("lowGenomes", mapToString(lowGenomes))//
            .append("averageMeasures", mapToString(averageMeasures))//
            .toString();
    assertThat("", //
            population.toString(), isEqualTo(expected));
    assertThat("", //
            population.getAgeLastImproved(), isEqualTo(0l));
    assertThat("", //
            population.getHighestGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isNull());
    assertThat("", //
            population.getLowestGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isNull());
    assertThat("", //
            population.getHighestEverGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isNull());
    assertThat("", //
            population.getLowestEverGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isNull());
    assertThat("", //
            population.getAverageGenomeAttribute(Genome.FITNESS_ATTRIBUTE_ID), isNull());
    population.validate();
    population.incrementAge();
    population.incrementAge();
    attributes.set(Population.AGE_ATTRIBUTE_ID, 2l);
    attributes.set(Population.GENOME_NUM_ATTRIBUTE_ID, 2);
    GenomeImpl genome0 = new GenomeImpl(0, "");
    GenomeImpl genome1 = new GenomeImpl(1, "");
    genome1.setAttribute(Genome.FITNESS_ATTRIBUTE_ID, 1.0);
    genome1.setAttribute(FLOAT_ID, 1.0f);
    genome1.setAttribute(LONG_ID, 1l);
    genome1.setAttribute(INTEGER_ID, 1);
    genome1.setAttribute(SHORT_ID, (short) 1);
    genome1.setAttribute(BYTE_ID, (byte) 1);
    population.add(genome0);
    population.add(genome1);
    expected = new ToStringBuilder(population, ToStringStyle.MULTI_LINE_STYLE)//
            .append("id", population.getId())//
            .append("size", 2)//
            .append("attributes", attributes)//
            .append("highGenomes", mapToString(highGenomes))//
            .append("lowGenomes", mapToString(lowGenomes))//
            .append("averageMeasures", mapToString(averageMeasures))//
            .toString();
    assertThat("", //
            population.toString(), isEqualTo(expected));
    assertThat("", //
            population.getAgeLastImproved(), isEqualTo(0l));
    assertThat("", //
            population.getHighestGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isNull());
    assertThat("", //
            population.getLowestGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isNull());
    assertThat("", //
            population.getHighestEverGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isNull());
    assertThat("", //
            population.getLowestEverGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isNull());
    assertThat("", //
            population.getAverageGenomeAttribute(Genome.FITNESS_ATTRIBUTE_ID), isNull());
    population.validate();
    population.refreshStats();
    attributes.set(Population.AGE_LI_ATTRIBUTE_ID, 2l);
    highGenomes.put(Genome.FITNESS_ATTRIBUTE_ID, genome1);
    highGenomes.put(Genome.AGE_ATTRIBUTE_ID, genome1);
    highGenomes.put(FLOAT_ID, genome1);
    highGenomes.put(LONG_ID, genome1);
    highGenomes.put(INTEGER_ID, genome1);
    highGenomes.put(SHORT_ID, genome1);
    highGenomes.put(BYTE_ID, genome1);
    highGenomes.put(Genome.COMPLEXITY_ATTRIBUTE_ID, genome1);
    highGenomes.put(Genome.EVAL_COUNT_ATTRIBUTE_ID, genome1);
    lowGenomes.put(Genome.FITNESS_ATTRIBUTE_ID, genome0);
    lowGenomes.put(Genome.AGE_ATTRIBUTE_ID, genome0);
    lowGenomes.put(FLOAT_ID, genome0);
    lowGenomes.put(LONG_ID, genome0);
    lowGenomes.put(INTEGER_ID, genome0);
    lowGenomes.put(SHORT_ID, genome0);
    lowGenomes.put(BYTE_ID, genome0);
    lowGenomes.put(Genome.COMPLEXITY_ATTRIBUTE_ID, genome0);
    lowGenomes.put(Genome.EVAL_COUNT_ATTRIBUTE_ID, genome0);
    averageMeasures.put(Genome.FITNESS_ATTRIBUTE_ID, 0.5);
    averageMeasures.put(Genome.AGE_ATTRIBUTE_ID, 0.0);
    averageMeasures.put(Genome.EVAL_COUNT_ATTRIBUTE_ID, 0.0);
    averageMeasures.put(Genome.COMPLEXITY_ATTRIBUTE_ID, 0.0);
    averageMeasures.put(FLOAT_ID, 0.5);
    averageMeasures.put(LONG_ID, 0.5);
    averageMeasures.put(INTEGER_ID, 0.5);
    averageMeasures.put(SHORT_ID, 0.5);
    averageMeasures.put(BYTE_ID, 0.5);
    expected = new ToStringBuilder(population, ToStringStyle.MULTI_LINE_STYLE)//
            .append("id", population.getId())//
            .append("size", 2)//
            .append("attributes", attributes)//
            .append("highGenomes", mapToString(highGenomes))//
            .append("lowGenomes", mapToString(lowGenomes))//
            .append("averageMeasures", mapToString(averageMeasures))//
            .toString();
    assertThat("", //
            population.toString(), isEqualTo(expected));
    assertThat("", //
            population.getAgeLastImproved(), isEqualTo(2l));
    assertThat("", //
            population.getHighestGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isSameAs(genome1));
    assertThat("", //
            population.getLowestGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isSameAs(genome0));
    assertThat("", //
            population.getHighestEverGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isSameAs(genome1));
    assertThat("", //
            population.getLowestEverGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isSameAs(genome0));
    assertThat("", //
            population.getAverageGenomeAttribute(Genome.FITNESS_ATTRIBUTE_ID), isEqualTo(0.5));
    population.validate();
    GenomeImpl genome2 = new GenomeImpl(2, "");
    genome2.setAttribute(Genome.FITNESS_ATTRIBUTE_ID, 5.0);
    genome2.setAttribute(FLOAT_ID, 5.0f);
    genome2.setAttribute(LONG_ID, 5l);
    genome2.setAttribute(INTEGER_ID, 5);
    genome2.setAttribute(SHORT_ID, (short) 0);
    genome2.setAttribute(BYTE_ID, (byte) 0);
    population.add(genome2);
    population.incrementAge();
    population.refreshStats();
    attributes.set(Population.AGE_ATTRIBUTE_ID, 3l);
    attributes.set(Population.AGE_LI_ATTRIBUTE_ID, 3l);
    attributes.set(Population.GENOME_NUM_ATTRIBUTE_ID, 3);
    highGenomes.put(Genome.FITNESS_ATTRIBUTE_ID, genome2);
    highGenomes.put(Genome.AGE_ATTRIBUTE_ID, genome2);
    highGenomes.put(LONG_ID, genome2);
    highGenomes.put(FLOAT_ID, genome2);
    highGenomes.put(INTEGER_ID, genome2);
    highGenomes.put(Genome.COMPLEXITY_ATTRIBUTE_ID, genome2);
    highGenomes.put(Genome.EVAL_COUNT_ATTRIBUTE_ID, genome2);
    averageMeasures.put(Genome.FITNESS_ATTRIBUTE_ID, 2.0);
    averageMeasures.put(Genome.AGE_ATTRIBUTE_ID, 1.0);
    averageMeasures.put(LONG_ID, 2.0);
    averageMeasures.put(FLOAT_ID, 2.0);
    averageMeasures.put(INTEGER_ID, 2.0);
    averageMeasures.put(SHORT_ID, 1 / 3.0);
    averageMeasures.put(BYTE_ID, 1 / 3.0);
    expected = new ToStringBuilder(population, ToStringStyle.MULTI_LINE_STYLE)//
            .append("id", population.getId())//
            .append("size", 3)//
            .append("attributes", attributes)//
            .append("highGenomes", mapToString(highGenomes))//
            .append("lowGenomes", mapToString(lowGenomes))//
            .append("averageMeasures", mapToString(averageMeasures))//
            .toString();
    assertThat("", //
            population.toString(), isEqualTo(expected));
    assertThat("", //
            population.getAgeLastImproved(), isEqualTo(3l));
    assertThat("", //
            population.getHighestGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isSameAs(genome2));
    assertThat("", //
            population.getLowestGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isSameAs(genome0));
    assertThat("", //
            population.getHighestEverGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isSameAs(genome2));
    assertThat("", //
            population.getLowestEverGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isSameAs(genome0));
    assertThat("", //
            population.getAverageGenomeAttribute(Genome.FITNESS_ATTRIBUTE_ID), isEqualTo(2.0));
    population.validate();
    population.add(genome2);
    population.refreshStats();
    assertThat("", //
            population.getHighestGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isSameAs(genome2));
    assertThat("", //
            population.getLowestGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isSameAs(genome0));
    assertThat("", //
            population.getHighestEverGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isSameAs(genome2));
    assertThat("", //
            population.getLowestEverGenomeByAttribute(Genome.FITNESS_ATTRIBUTE_ID), isSameAs(genome0));
}

From source file:com.google.code.mymon3y.model.Transacao.java

@Override
public String toString() {
    return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", id)
            .append("descricao", descricao).append("data", data).append("valor", valor)
            .append("comentario", comentario).append("dataAvisoPrevio", dataAvisoPrevio)
            .append("credito", credito).append("categoria", categoria).toString();
}

From source file:com.gemini.provision.loadbalancer.openstack.LoadBalancerProviderOpenStackImpl.java

@Override
public List<GeminiLoadBalancerPool> listAllPools(GeminiTenant tenant, GeminiEnvironment env) {
    List<GeminiLoadBalancerPool> lbPools = Collections.synchronizedList(new ArrayList());

    //authenticate the session with the OpenStack installation
    OSClient os = OSFactory.builder().endpoint(env.getEndPoint())
            .credentials(env.getAdminUserName(), env.getAdminPassword()).tenantName(tenant.getName())
            .authenticate();//from  ww  w  .  jav a  2s. c  o  m
    if (os == null) {
        Logger.error("Failed to authenticate Tenant: {}",
                ToStringBuilder.reflectionToString(tenant, ToStringStyle.MULTI_LINE_STYLE));
        return null;
    }
    List<? extends LbPool> osLbPools = os.networking().loadbalancers().lbPool().list();

    osLbPools.stream().filter(lbPool -> lbPool != null).forEach(lbPool -> {
        GeminiLoadBalancerPool loadBalancerPool = new GeminiLoadBalancerPool();
        loadBalancerPool.setCloudID(lbPool.getId());
        loadBalancerPool.setName(lbPool.getName());
        loadBalancerPool.setDescription(lbPool.getDescription());
        //TODO get the VpId from the pool
        loadBalancerPool.setVipID(lbPool.getVipId());
        loadBalancerPool.setProtocol(Protocol.fromString(lbPool.getProtocol()));
        loadBalancerPool.setLoadBalancerAlgorithm(LoadBalancerAlgorithm.fromString(lbPool.getLbMethod()));
        //TODO set the pool member
        loadBalancerPool.setAdminState(lbPool.isAdminStateUp() ? AdminState.ADMIN_UP : AdminState.ADMIN_DOWN);

        GeminiSubnet subnet = env.getApplications().stream().map(GeminiApplication::getNetworks)
                .flatMap(List::stream).map(GeminiNetwork::getSubnets).flatMap(List::stream)
                .filter(s -> s.getCloudID().equals(lbPool.getId())).findFirst().get();
        if (subnet == null) {
            Logger.info(
                    "Load Balancer cloud ID {} references a subnet not available in environment {}  Subnet ID: {}",
                    lbPool.getId(), env.getName(), lbPool.getSubnetId());
        } else {
            loadBalancerPool.setGeminiSubnet(subnet);
        }
        lbPools.add(loadBalancerPool);
    });

    return lbPools;
}

From source file:com.jeefuse.system.security.model.GsysFunction.java

/** @generated */
@Override//  w w  w  . ja  va  2  s.  c  om
public String toString() {
    return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId())
            .append("value", value).append("name", name).append("descript", descript).append("type", type)
            .append("url", url).append("validStatus", validStatus).append("sortNum", sortNum)
            .append("layerCode", layerCode).toString();
}

From source file:com.likethecolor.alchemy.api.entity.AlchemyVerbTest.java

@Test
public void testToString_Formatted() {
    final boolean isNegated = true;
    final String text = "find";
    final AlchemyVerb.TENSE tense = AlchemyVerb.TENSE.PAST;
    final ToStringStyle style = ToStringStyle.MULTI_LINE_STYLE;

    final AlchemyVerb entity = new AlchemyVerb();

    final String expectedString = new ToStringBuilder(entity, style).append("is negated", isNegated)
            .append("tense", tense).append("text", text).toString();

    entity.setIsNegated(isNegated);/*from  w w  w . ja v  a2 s.  c om*/
    entity.setTense(tense);
    entity.setText(text);

    final String actualString = entity.toString(style);

    assertEquals(expectedString, actualString);
}