AutoValue: Nested toString() Extension

AutoValue extension for prepending the enclosing classes names to a nested class's toString().

License

License

Categories

Categories

Auto Application Layer Libs Code Generators
GroupId

GroupId

com.christiangp
ArtifactId

ArtifactId

auto-value-nested-tostring
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

AutoValue: Nested toString() Extension
AutoValue extension for prepending the enclosing classes names to a nested class's toString().
Project URL

Project URL

https://github.com/ChristianGarcia/auto-value-nested-tostring/
Source Code Management

Source Code Management

https://github.com/ChristianGarcia/auto-value-nested-tostring/

Download auto-value-nested-tostring

How to add to project

<!-- https://jarcasting.com/artifacts/com.christiangp/auto-value-nested-tostring/ -->
<dependency>
    <groupId>com.christiangp</groupId>
    <artifactId>auto-value-nested-tostring</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.christiangp/auto-value-nested-tostring/
implementation 'com.christiangp:auto-value-nested-tostring:0.2.0'
// https://jarcasting.com/artifacts/com.christiangp/auto-value-nested-tostring/
implementation ("com.christiangp:auto-value-nested-tostring:0.2.0")
'com.christiangp:auto-value-nested-tostring:jar:0.2.0'
<dependency org="com.christiangp" name="auto-value-nested-tostring" rev="0.2.0">
  <artifact name="auto-value-nested-tostring" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.christiangp', module='auto-value-nested-tostring', version='0.2.0')
)
libraryDependencies += "com.christiangp" % "auto-value-nested-tostring" % "0.2.0"
[com.christiangp/auto-value-nested-tostring "0.2.0"]

Dependencies

compile (2)

Group / Artifact Type Version
com.squareup : javapoet jar 1.8.0
com.google.auto.value : auto-value jar 1.4

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
com.google.truth : truth jar 0.32
com.google.testing.compile : compile-testing jar 0.9

Project Modules

There are no modules declared in this project.

AutoValue: Nested toString()

Build Status

An extension for Google's AutoValue that prepends the enclosing classes' names to the toString() method of a @Nested annotated nested class.

Usage

Apply the @Nested annotation to any nested class whose toString() you wish to modify in order to include the enclosing classes.

public class TopLevelClass {

  public static class NestedClass {
  
    @AutoValue
    @Nested
    public static abstract class NestedInNestedClass {
       public abstract String property();
    }
  }
}

When you call a NestedInNestedClass instance's toString() this will include the enclosing classes at the beginning

TopLevelClass.NestedClass.NestedInNestedClass{property=name} //auto-value-nested-tostring

as opposed to AutoValue's default (simple class name)

NestedInNestedClass{property=name} //AutoValue's default

Download

Add a Gradle dependency:

annotationProcessor 'com.christiangp:auto-value-nested-tostring:<latest_version>'
provided 'com.christiangp:auto-value-nested-tostring-annotations:<latest_version>'

or Maven:

<dependency>
  <groupId>com.christiangp</groupId>
  <artifactId>auto-value-nested-tostring</artifactId>
  <version>$latest_version</version>
  <scope>provided</scope>
</dependency>

License

Copyright (c) 2017 Christian García

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.

Versions

Version
0.2.0
0.1.0