11/*
2- Copyright 2021 The TensorFlow Authors. All Rights Reserved.
2+ Copyright 2021 The TensorFlow Authors. All Rights Reserved.
33
4- Licensed under the Apache License, Version 2.0 (the "License");
5- you may not use this file except in compliance with the License.
6- You may obtain a copy of the License at
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
77
8- http://www.apache.org/licenses/LICENSE-2.0
8+ http://www.apache.org/licenses/LICENSE-2.0
99
10- Unless required by applicable law or agreed to in writing, software
11- distributed under the License is distributed on an "AS IS" BASIS,
12- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- See the License for the specific language governing permissions and
14- limitations under the License.
15- ==============================================================================
16- */
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+ ==============================================================================
16+ */
1717package org .tensorflow .op .generator ;
1818
1919import com .squareup .javapoet .ArrayTypeName ;
2222import com .squareup .javapoet .TypeName ;
2323import com .squareup .javapoet .TypeVariableName ;
2424import com .squareup .javapoet .WildcardTypeName ;
25+ import org .tensorflow .Names ;
26+
2527import java .util .Collections ;
2628import java .util .LinkedHashSet ;
2729import java .util .List ;
2830import java .util .Objects ;
2931import java .util .Set ;
3032import java .util .StringJoiner ;
31- import org .tensorflow .Names ;
3233
33- /**
34- * Holds type information for inputs, outputs, or attributes, and provides utilities.
35- */
34+ /** Holds type information for inputs, outputs, or attributes, and provides utilities. */
3635final class ResolvedType {
3736
38- /**
39- * The java level type.
40- */
37+ /** The java level type. */
4138 final TypeName javaType ;
4239
43- /**
44- * The type for jni/attribute setting use.
45- */
40+ /** The type for jni/attribute setting use. */
4641 final TypeName jniType ;
4742
4843 /**
4944 * Whether this type should be made iterable when used.
50- * <p>
5145 *
52- * See {@link #arrayIfIterable()}, {@link #listIfIterable()}, {@link #iterableIfIterable()}.
46+ * <p> See {@link #arrayIfIterable()}, {@link #listIfIterable()}, {@link #iterableIfIterable()}.
5347 */
5448 final boolean iterable ;
5549
@@ -105,16 +99,12 @@ final class ResolvedType {
10599 this (type , false );
106100 }
107101
108- /**
109- * Returns a copy of this type with the specified {@code iterable} value.
110- */
102+ /** Returns a copy of this type with the specified {@code iterable} value. */
111103 ResolvedType withIterable (boolean iterable ) {
112104 return new ResolvedType (javaType , jniType , iterable );
113105 }
114106
115- /**
116- * Get the unboxed version of {@code javaType} if it is a boxed primitive.
117- */
107+ /** Get the unboxed version of {@code javaType} if it is a boxed primitive. */
118108 TypeName unboxed () {
119109 if (javaType .isBoxedPrimitive ()) {
120110 return javaType .unbox ();
@@ -123,9 +113,7 @@ TypeName unboxed() {
123113 }
124114 }
125115
126- /**
127- * Return a copy, wrapping {@code javaType} in an array if this type is iterable.
128- */
116+ /** Return a copy, wrapping {@code javaType} in an array if this type is iterable. */
129117 ResolvedType arrayIfIterable () {
130118 TypeName newJType ;
131119 if (iterable ) {
@@ -136,9 +124,7 @@ ResolvedType arrayIfIterable() {
136124 return new ResolvedType (newJType , jniType , iterable );
137125 }
138126
139- /**
140- * Return a copy, wrapping {@code javaType} in {@link Iterable} if this type is iterable.
141- */
127+ /** Return a copy, wrapping {@code javaType} in {@link Iterable} if this type is iterable. */
142128 ResolvedType iterableIfIterable () {
143129 TypeName newJType ;
144130 if (iterable ) {
@@ -149,9 +135,7 @@ ResolvedType iterableIfIterable() {
149135 return new ResolvedType (newJType , jniType , iterable );
150136 }
151137
152- /**
153- * Return a copy, wrapping {@code javaType} in {@link List} if this type is iterable.
154- */
138+ /** Return a copy, wrapping {@code javaType} in {@link List} if this type is iterable. */
155139 ResolvedType listIfIterable () {
156140 TypeName newJType ;
157141 if (iterable ) {
@@ -162,15 +146,14 @@ ResolvedType listIfIterable() {
162146 return new ResolvedType (newJType , jniType , iterable );
163147 }
164148
165- /**
166- * True if wrapping will be done by {@link #classIfGeneric()}
167- */
149+ /** True if wrapping will be done by {@link #classIfGeneric()} */
168150 boolean shouldWrapInClass () {
169151 return javaType instanceof TypeVariableName || javaType instanceof WildcardTypeName ;
170152 }
171153
172154 /**
173- * Return a copy, wrapping {@code javaType} in {@link Class} if it is a single type variable or a wildcard.
155+ * Return a copy, wrapping {@code javaType} in {@link Class} if it is a single type variable or a
156+ * wildcard.
174157 */
175158 ResolvedType classIfGeneric () {
176159 TypeName newJType ;
@@ -182,9 +165,7 @@ ResolvedType classIfGeneric() {
182165 return new ResolvedType (newJType , jniType , iterable );
183166 }
184167
185- /**
186- * Recursively get all type variable names in {@code javaType}.
187- */
168+ /** Recursively get all type variable names in {@code javaType}. */
188169 Set <TypeVariableName > findGenerics () {
189170 if (javaType instanceof TypeVariableName ) {
190171 return Collections .singleton ((TypeVariableName ) javaType );
@@ -199,7 +180,8 @@ Set<TypeVariableName> findGenerics() {
199180 }
200181
201182 /**
202- * Return the type argument if {@code javaType} is {@code Operand} or {@code Output}, or return {@code javaType}.
183+ * Return the type argument if {@code javaType} is {@code Operand} or {@code Output}, or return
184+ * {@code javaType}.
203185 */
204186 TypeName unwrapArg () {
205187 if (javaType instanceof ParameterizedTypeName ) {
@@ -220,8 +202,9 @@ public boolean equals(Object o) {
220202 return false ;
221203 }
222204 ResolvedType that = (ResolvedType ) o ;
223- return iterable == that .iterable && Objects .equals (javaType , that .javaType ) && Objects
224- .equals (jniType , that .jniType );
205+ return iterable == that .iterable
206+ && Objects .equals (javaType , that .javaType )
207+ && Objects .equals (jniType , that .jniType );
225208 }
226209
227210 @ Override
0 commit comments