org.immutables.fixture.encoding.defs.OptionalIntWithSentinelEnabled Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of value-fixture Show documentation
Show all versions of value-fixture Show documentation
Module that contains all tests for the code generation capability
package org.immutables.fixture.encoding.defs;
import org.immutables.encode.EncodingMetadata;
@EncodingMetadata(
name = "org.immutables.fixture.encoding.defs.OptionalIntWithSentinel",
imports = {
"static com.google.common.base.Preconditions.checkArgument"
},
typeParams = {},
elements = {
@EncodingMetadata.Element(
name = "value",
tags = {"IMPL", "PRIVATE", "FINAL", "FIELD"},
naming = "*",
stdNaming = "NONE",
type = "int",
typeParams = {},
params = {},
doc = {},
annotations = {},
code = "",
thrown = {}
),
@EncodingMetadata.Element(
name = "initFrom",
tags = {"STATIC", "PRIVATE", "FROM"},
naming = "*_initFrom",
stdNaming = "NONE",
type = "int",
typeParams = {},
params = {"optional: java.util.OptionalInt"},
doc = {},
annotations = {},
code = "{\nif (@^optional.isPresent()) {\nreturn @:safeValue(@^optional.getAsInt());\n}\nreturn @@SENTINEL_VALUE;\n}",
thrown = {}
),
@EncodingMetadata.Element(
name = "toString",
tags = {"PRIVATE", "TO_STRING"},
naming = "*_toString",
stdNaming = "NONE",
type = "java.lang.String",
typeParams = {},
params = {},
doc = {},
annotations = {},
code = "{\nreturn String.valueOf(@:get());\n}",
thrown = {}
),
@EncodingMetadata.Element(
name = "hashCode",
tags = {"PRIVATE", "HASH_CODE"},
naming = "*_hashCode",
stdNaming = "NONE",
type = "int",
typeParams = {},
params = {},
doc = {},
annotations = {},
code = "{\nreturn @@value;\n}",
thrown = {}
),
@EncodingMetadata.Element(
name = "equals",
tags = {"PRIVATE", "EQUALS"},
naming = "*_equals",
stdNaming = "NONE",
type = "boolean",
typeParams = {},
params = {"that: org.immutables.fixture.encoding.defs.OptionalIntWithSentinel"},
doc = {},
annotations = {},
code = "{\nreturn this.@@value == @^that.@@value;\n}",
thrown = {}
),
@EncodingMetadata.Element(
name = "build",
tags = {"BUILDER", "PRIVATE", "BUILD"},
naming = "*_build",
stdNaming = "NONE",
type = "int",
typeParams = {},
params = {},
doc = {},
annotations = {},
code = "{\nreturn @@value;\n}",
thrown = {}
),
@EncodingMetadata.Element(
name = "SENTINEL_VALUE",
tags = {"STATIC", "PRIVATE", "FINAL", "FIELD"},
naming = "*_SENTINEL_VALUE",
stdNaming = "NONE",
type = "int",
typeParams = {},
params = {},
doc = {},
annotations = {},
code = "0",
thrown = {}
),
@EncodingMetadata.Element(
name = "get",
tags = {"EXPOSE"},
naming = "*",
stdNaming = "NONE",
type = "java.util.OptionalInt",
typeParams = {},
params = {},
doc = {},
annotations = {},
code = "{\nif (@@value != @@SENTINEL_VALUE) {\nreturn java.util.OptionalInt.of(@@value);\n}\nreturn java.util.OptionalInt.empty();\n}",
thrown = {}
),
@EncodingMetadata.Element(
name = "withOptional",
tags = {"COPY"},
naming = "*",
stdNaming = "NONE",
type = "int",
typeParams = {},
params = {"optional: java.util.OptionalInt"},
doc = {},
annotations = {},
code = "{\nreturn @:initFrom(@^optional);\n}",
thrown = {}
),
@EncodingMetadata.Element(
name = "withInt",
tags = {"COPY"},
naming = "*",
stdNaming = "NONE",
type = "int",
typeParams = {},
params = {"intValue: int"},
doc = {},
annotations = {},
code = "{\nreturn @:safeValue(@^intValue);\n}",
thrown = {}
),
@EncodingMetadata.Element(
name = "withInteger",
tags = {"COPY"},
naming = "*",
stdNaming = "NONE",
type = "int",
typeParams = {},
params = {"integer: java.lang.Integer"},
doc = {},
annotations = {},
code = "{\nreturn @^integer != null ? @:safeValue(@^integer.intValue()) : @@SENTINEL_VALUE;\n}",
thrown = {}
),
@EncodingMetadata.Element(
name = "safeValue",
tags = {"STATIC", "PRIVATE", "HELPER"},
naming = "*_safeValue",
stdNaming = "NONE",
type = "int",
typeParams = {},
params = {"intValue: int"},
doc = {},
annotations = {},
code = "{\ncheckArgument(@^intValue != @@SENTINEL_VALUE, \"Field value can\'t match the sentinel\");\nreturn @^intValue;\n}",
thrown = {}
),
@EncodingMetadata.Element(
name = "value",
tags = {"BUILDER", "PRIVATE", "FIELD"},
naming = "*_value",
stdNaming = "NONE",
type = "int",
typeParams = {},
params = {},
doc = {},
annotations = {},
code = "@@SENTINEL_VALUE",
thrown = {}
),
@EncodingMetadata.Element(
name = "setFrom",
tags = {"BUILDER", "INIT", "COPY"},
naming = "*",
stdNaming = "NONE",
type = "void",
typeParams = {},
params = {"optional: java.util.OptionalInt"},
doc = {},
annotations = {},
code = "{\nif (@^optional.isPresent()) {\n@:setFromInt(@^optional.getAsInt());\n} else {\n@@value = @@SENTINEL_VALUE;\n}\n}",
thrown = {}
),
@EncodingMetadata.Element(
name = "setFromInteger",
tags = {"BUILDER", "INIT"},
naming = "*",
stdNaming = "NONE",
type = "void",
typeParams = {},
params = {"value: java.lang.Integer"},
doc = {},
annotations = {},
code = "{\nif (@^value != null) {\n@:setFromInt(@^value.intValue());\n} else {\n@^value = @@SENTINEL_VALUE;\n}\n}",
thrown = {}
),
@EncodingMetadata.Element(
name = "setFromInt",
tags = {"BUILDER", "INIT"},
naming = "*",
stdNaming = "NONE",
type = "void",
typeParams = {},
params = {"value: int"},
doc = {},
annotations = {},
code = "{\nthis.@@value = @:safeValue(@^value);\n}",
thrown = {}
)
}
)
public @interface OptionalIntWithSentinelEnabled {}