1
1
/*
2
- Copyright 2021 The TensorFlow Authors. All Rights Reserved.
2
+ Copyright 2021 The TensorFlow Authors. All Rights Reserved.
3
3
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
7
7
8
- http://www.apache.org/licenses/LICENSE-2.0
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
9
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
+ */
17
17
package org .tensorflow .op .generator ;
18
18
19
19
import com .squareup .javapoet .ArrayTypeName ;
22
22
import com .squareup .javapoet .TypeName ;
23
23
import com .squareup .javapoet .TypeVariableName ;
24
24
import com .squareup .javapoet .WildcardTypeName ;
25
+ import org .tensorflow .Names ;
26
+
25
27
import java .util .Collections ;
26
28
import java .util .LinkedHashSet ;
27
29
import java .util .List ;
28
30
import java .util .Objects ;
29
31
import java .util .Set ;
30
32
import java .util .StringJoiner ;
31
- import org .tensorflow .Names ;
32
33
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. */
36
35
final class ResolvedType {
37
36
38
- /**
39
- * The java level type.
40
- */
37
+ /** The java level type. */
41
38
final TypeName javaType ;
42
39
43
- /**
44
- * The type for jni/attribute setting use.
45
- */
40
+ /** The type for jni/attribute setting use. */
46
41
final TypeName jniType ;
47
42
48
43
/**
49
44
* Whether this type should be made iterable when used.
50
- * <p>
51
45
*
52
- * See {@link #arrayIfIterable()}, {@link #listIfIterable()}, {@link #iterableIfIterable()}.
46
+ * <p> See {@link #arrayIfIterable()}, {@link #listIfIterable()}, {@link #iterableIfIterable()}.
53
47
*/
54
48
final boolean iterable ;
55
49
@@ -105,16 +99,12 @@ final class ResolvedType {
105
99
this (type , false );
106
100
}
107
101
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. */
111
103
ResolvedType withIterable (boolean iterable ) {
112
104
return new ResolvedType (javaType , jniType , iterable );
113
105
}
114
106
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. */
118
108
TypeName unboxed () {
119
109
if (javaType .isBoxedPrimitive ()) {
120
110
return javaType .unbox ();
@@ -123,9 +113,7 @@ TypeName unboxed() {
123
113
}
124
114
}
125
115
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. */
129
117
ResolvedType arrayIfIterable () {
130
118
TypeName newJType ;
131
119
if (iterable ) {
@@ -136,9 +124,7 @@ ResolvedType arrayIfIterable() {
136
124
return new ResolvedType (newJType , jniType , iterable );
137
125
}
138
126
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. */
142
128
ResolvedType iterableIfIterable () {
143
129
TypeName newJType ;
144
130
if (iterable ) {
@@ -149,9 +135,7 @@ ResolvedType iterableIfIterable() {
149
135
return new ResolvedType (newJType , jniType , iterable );
150
136
}
151
137
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. */
155
139
ResolvedType listIfIterable () {
156
140
TypeName newJType ;
157
141
if (iterable ) {
@@ -162,15 +146,14 @@ ResolvedType listIfIterable() {
162
146
return new ResolvedType (newJType , jniType , iterable );
163
147
}
164
148
165
- /**
166
- * True if wrapping will be done by {@link #classIfGeneric()}
167
- */
149
+ /** True if wrapping will be done by {@link #classIfGeneric()} */
168
150
boolean shouldWrapInClass () {
169
151
return javaType instanceof TypeVariableName || javaType instanceof WildcardTypeName ;
170
152
}
171
153
172
154
/**
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.
174
157
*/
175
158
ResolvedType classIfGeneric () {
176
159
TypeName newJType ;
@@ -182,9 +165,7 @@ ResolvedType classIfGeneric() {
182
165
return new ResolvedType (newJType , jniType , iterable );
183
166
}
184
167
185
- /**
186
- * Recursively get all type variable names in {@code javaType}.
187
- */
168
+ /** Recursively get all type variable names in {@code javaType}. */
188
169
Set <TypeVariableName > findGenerics () {
189
170
if (javaType instanceof TypeVariableName ) {
190
171
return Collections .singleton ((TypeVariableName ) javaType );
@@ -199,7 +180,8 @@ Set<TypeVariableName> findGenerics() {
199
180
}
200
181
201
182
/**
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}.
203
185
*/
204
186
TypeName unwrapArg () {
205
187
if (javaType instanceof ParameterizedTypeName ) {
@@ -220,8 +202,9 @@ public boolean equals(Object o) {
220
202
return false ;
221
203
}
222
204
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 );
225
208
}
226
209
227
210
@ Override
0 commit comments