本文整理汇总了Java中org.checkerframework.checker.nullness.qual.Nullable类的典型用法代码示例。如果您正苦于以下问题:Java Nullable类的具体用法?Java Nullable怎么用?Java Nullable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Nullable类属于org.checkerframework.checker.nullness.qual包,在下文中一共展示了Nullable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: giveLengthyNodesSamePosition
import org.checkerframework.checker.nullness.qual.Nullable; //导入依赖的package包/类
/**
* Puts lengthy nodes in the same position in the results as their parent.
*
* @param layer1 the nodes in layer 1
* @param layer2 the nodes in layer 2
* @param newLayer2 the results of the current iteration
* @return map from position in results to lengthy nodes
*/
private Map<Integer, LayoutableNode> giveLengthyNodesSamePosition(final LayoutableNode[] layer1,
final LayoutableNode[] layer2,
final List<@Nullable LayoutableNode> newLayer2) {
final Map<Integer, LayoutableNode> lengthy = new LinkedHashMap<>();
Arrays.stream(layer2).forEach(layer2Node -> {
final int layer1Position = ArrayUtils.indexOf(layer1, layer2Node);
if (layer1Position > -1) {
enlargeList(newLayer2, layer1Position + 1);
newLayer2.set(layer1Position, layer2Node);
lengthy.put(layer1Position, layer2Node);
}
});
return lengthy;
}
示例2: addDummyNodesBetweenWideChildrenNodesAndLengthyNodes
import org.checkerframework.checker.nullness.qual.Nullable; //导入依赖的package包/类
/**
* Adds dummy nodes between nodes with a large children width and lengthy nodes, in order to move lengthy nodes
* to the right.
*
* @param newLayer2 the result of the current iteration
* @param layer2Index the index of the second layer
* @param layers the layers
*/
@SuppressWarnings("squid:ForLoopCounterChangedCheck") // For this specific implementation this is not a problem
private void addDummyNodesBetweenWideChildrenNodesAndLengthyNodes(final List<@Nullable LayoutableNode> newLayer2,
final int layer2Index,
final LayoutableNode[][] layers) {
for (int i = 0; i < newLayer2.size() - 1; i++) {
final LayoutableNode node = newLayer2.get(i);
final LayoutableNode rightNeighbour = newLayer2.get(i + 1);
if (node == null || rightNeighbour == null) {
continue;
}
if (lengthyNodeFinder.isLengthy(rightNeighbour, layer2Index, layers)) {
final int childrenWidth = getMaxChildrenWidth(node);
for (int child = 0; child < childrenWidth - 1; child++) {
newLayer2.add(i + 1, null);
}
if (childrenWidth > 0) {
i += childrenWidth - 1;
}
}
}
}
示例3: getType
import org.checkerframework.checker.nullness.qual.Nullable; //导入依赖的package包/类
private Type getType(String name) {
@Nullable Type type = types.get(name);
if (type != null) {
return type;
}
@Nullable ClassNode clazz = application.getClass(name);
if (clazz != null) {
type = new AsmType(clazz);
} else {
try {
type = new JavaType(Class.forName(name.replace('/', '.'), false, dependencyClassLoader));
} catch (ClassNotFoundException ex) {
throw new RuntimeException(ex);
}
}
types.put(name, type);
return type;
}
示例4: AutoValue_ImmutableChoice
import org.checkerframework.checker.nullness.qual.Nullable; //导入依赖的package包/类
AutoValue_ImmutableChoice(
Supply supply,
Demand demand,
double score,
@Nullable HashMap<String, Double> scoreComponents) {
if (supply == null) {
throw new NullPointerException("Null supply");
}
this.supply = supply;
if (demand == null) {
throw new NullPointerException("Null demand");
}
this.demand = demand;
this.score = score;
this.scoreComponents = scoreComponents;
}
示例5: getMutableViewData
import org.checkerframework.checker.nullness.qual.Nullable; //导入依赖的package包/类
@javax.annotation.Nullable
private synchronized MutableViewData getMutableViewData(View.Name viewName) {
View view = registeredViews.get(viewName);
if (view == null) {
return null;
}
Collection<MutableViewData> views = mutableMap.get(view.getMeasure().getName());
for (MutableViewData viewData : views) {
if (viewData.getView().getName().equals(viewName)) {
return viewData;
}
}
throw new AssertionError(
"Internal error: Not recording stats for view: \""
+ viewName
+ "\" registeredViews="
+ registeredViews
+ ", mutableMap="
+ mutableMap);
}
示例6: evaluate
import org.checkerframework.checker.nullness.qual.Nullable; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
@Nullable
public List<Term> evaluate(Scope s, Monitor m) {
List<Term> list = new ArrayList<Term>();
List<Term> te1 = t1.evaluate(s, m);
if (te1 == null)
return null;
List<Term> te2 = t2.evaluate(s, m);
if (te2 == null)
return null;
list.addAll(te1);
if (!te1.isEmpty() && !te2.isEmpty() && te1.get(te1.size() - 1) instanceof IntegerValue
&& te2.get(0) instanceof IntegerValue)
for (int k = ((IntegerValue) te1.get(te1.size() - 1)).getValue() + 1; k < ((IntegerValue) te2.get(0))
.getValue(); k++)
list.add(new IntegerValue(k));
if (!te1.equals(te2))
list.addAll(te2);
return list;
}
示例7: evaluate
import org.checkerframework.checker.nullness.qual.Nullable; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public @Nullable ConstraintHypergraph evaluate(Scope s, Monitor m) {
for (RuleNode r : getRuleNodes()) {
r.evaluate(s, m);
}
for (Term t : initial.keySet()) {
if (s.get(new Identifier(initial.get(t).toString())) != null) {
Value v = s.get(new Identifier(initial.get(t).toString()));
if (v instanceof StringValue)
initial.put(t, new Function("constant", ((StringValue) v).getValue(), new ArrayList<Term>()));
if (v instanceof BooleanValue)
initial.put(t, new Function("constant", ((BooleanValue) v).getValue(), new ArrayList<Term>()));
if (v instanceof IntegerValue)
initial.put(t, new Function("constant", ((IntegerValue) v).getValue(), new ArrayList<Term>()));
if (v instanceof DecimalValue)
initial.put(t, new Function("constant", ((DecimalValue) v).getValue(), new ArrayList<Term>()));
}
}
return new ConstraintHypergraph(getRules(), initial);
// If a new constraint hypergraph is not created, all instances of the
// same component definition will have shared rules and shared
// hyperedges.
// return new ConstraintHypergraph(new ArrayList<>(hyperedges),initial);
}
示例8: equals
import org.checkerframework.checker.nullness.qual.Nullable; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean equals(@Nullable Object other) {
if (other == null)
return false;
if (other == this)
return true;
if (!(other instanceof Conjunction))
return false;
// Set<Formula> s = new HashSet<>(this.getClauses());
// Set<Formula> s2 = new HashSet<>(((Conjunction)other).getClauses());
//
// return Objects.equals(s, s2);
return Objects.equals(this.getClausesSet(), ((Conjunction)other).getClausesSet());
}
示例9: parse
import org.checkerframework.checker.nullness.qual.Nullable; //导入依赖的package包/类
/**
* Parses a source file using ANTLR4, and walks over the parse tree to
* interpret this source file as a Java object.
*
* @param c
* input character stream
* @param path
* location of the file
* @return an interpreted source file, or null in case of an error.
*/
@Nullable
private ReoFile<T> parse(CharStream c, String path) {
ReoLexer lexer = new ReoLexer(c);
CommonTokenStream tokens = new CommonTokenStream(lexer);
ReoParser parser = new ReoParser(tokens);
ErrorListener errListener = new ErrorListener(m);
parser.removeErrorListeners();
parser.addErrorListener(errListener);
ParseTree tree = parser.file();
if (errListener.hasError)
return null;
ParseTreeWalker walker = new ParseTreeWalker();
listener.setFileName(path);
walker.walk(listener, tree);
return listener.getMain();
}
示例10: createOnSensorChangedListenerMethod
import org.checkerframework.checker.nullness.qual.Nullable; //导入依赖的package包/类
/**
* Creates the implementation of {@code SensorEventListener#onSensorChanged(SensorEvent)} which
* calls the annotated method on our target class.
*
* @param annotatedMethod Method annotated with {@code OnSensorChanged}.
* @return {@link MethodSpec} of {@code SensorEventListener#onSensorChanged(SensorEvent)}.
*/
@NonNull
private static MethodSpec createOnSensorChangedListenerMethod(
@Nullable AnnotatedMethod annotatedMethod) {
ParameterSpec sensorEventParameter = ParameterSpec.builder(SENSOR_EVENT, "event").build();
Builder methodBuilder =
getBaseMethodBuilder("onSensorChanged").addParameter(sensorEventParameter);
if (annotatedMethod != null) {
ExecutableElement sensorChangedExecutableElement =
annotatedMethod.getExecutableElement();
methodBuilder.addStatement("target.$L($N)",
sensorChangedExecutableElement.getSimpleName(), sensorEventParameter);
}
return methodBuilder.build();
}
示例11: createOnAccuracyChangedListenerMethod
import org.checkerframework.checker.nullness.qual.Nullable; //导入依赖的package包/类
/**
* Creates the implementation of {@code SensorEventListener#onAccuracyChanged(Sensor, int)}
* which calls the annotated method on our target class.
*
* @param annotatedMethod Method annotated with {@link OnAccuracyChanged}.
* @return {@link MethodSpec} of {@code SensorEventListener#onAccuracyChanged(Sensor, int)}.
*/
@NonNull
private static MethodSpec createOnAccuracyChangedListenerMethod(
@Nullable AnnotatedMethod annotatedMethod) {
ParameterSpec sensorParameter = ParameterSpec.builder(SENSOR, "sensor").build();
ParameterSpec accuracyParameter = ParameterSpec.builder(TypeName.INT, "accuracy").build();
Builder methodBuilder =
getBaseMethodBuilder("onAccuracyChanged").addParameter(sensorParameter)
.addParameter(accuracyParameter);
if (annotatedMethod != null) {
ExecutableElement accuracyChangedExecutableElement =
annotatedMethod.getExecutableElement();
methodBuilder.addStatement("target.$L($N, $N)",
accuracyChangedExecutableElement.getSimpleName(), sensorParameter,
accuracyParameter);
}
return methodBuilder.build();
}
示例12: getProviderDetailsFromId
import org.checkerframework.checker.nullness.qual.Nullable; //导入依赖的package包/类
@Override
public ProviderDetails getProviderDetailsFromId(@Nullable String oneZoneEndpoint,
String oneDataToken, String oneSpaceId, String oneProviderId) {
URI requestUri = UriBuilder
.fromUri(getOneZoneBaseEndpoint(oneZoneEndpoint)
+ "/spaces/{oneSpaceId}/providers/{oneProviderId}")
.build(oneSpaceId, oneProviderId)
.normalize();
try {
return restTemplate
.exchange(requestUri, HttpMethod.GET, withToken(oneDataToken), ProviderDetails.class)
.getBody();
} catch (RuntimeException ex) {
throw new DeploymentException(
String.format("Error retrieving details for OneData provider %s (space %s)",
oneProviderId, oneSpaceId),
ex);
}
}
示例13: executeWithClient
import org.checkerframework.checker.nullness.qual.Nullable; //导入依赖的package包/类
protected <R> R executeWithClient(URI requestUri, OidcTokenId tokenId,
BiFunction<URI, @Nullable String, R> function) {
if (!oidcProperties.isEnabled()) {
return function.apply(requestUri, null);
}
try {
String accessToken = oauth2TokenService.getAccessToken(tokenId);
return function.apply(requestUri, accessToken);
} catch (HttpClientErrorException ex) {
if (HttpStatus.UNAUTHORIZED == ex.getStatusCode()) {
String refreshedAccessToken = oauth2TokenService.getRefreshedAccessToken(tokenId);
return function.apply(requestUri, refreshedAccessToken);
} else {
throw ex;
}
}
}
示例14: getUserSpacesId
import org.checkerframework.checker.nullness.qual.Nullable; //导入依赖的package包/类
@Override
public UserSpaces getUserSpacesId(@Nullable String oneZoneEndpoint, String oneDataToken) {
URI requestUri = UriBuilder
.fromUri(getOneZoneBaseEndpoint(oneZoneEndpoint) + "/user/spaces")
.build()
.normalize();
try {
return restTemplate
.exchange(requestUri, HttpMethod.GET, withToken(oneDataToken), UserSpaces.class)
.getBody();
} catch (RuntimeException ex) {
throw new DeploymentException("Error retrieving OneData spaces", ex);
}
}
示例15: fromJson
import org.checkerframework.checker.nullness.qual.Nullable; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static JobStatus fromJson(URI uri, @Nullable String jsonStr) {
val json = (jsonStr == null || jsonStr.trim().isEmpty()) ? "{}" : jsonStr;
val map = (Map<String, Object>)new Yaml().loadAs(json, Map.class);
val transactionId = (Long)map.getOrDefault("transactionID", -1L);
val jobExecutionId = (Long)map.getOrDefault("jobExecutionId", -1L);
val startTimeStr = (String)map.getOrDefault("startTime", DATE_TIME_FORMATTER.format(now()));
val startTime = OffsetDateTime.parse(startTimeStr, DATE_TIME_FORMATTER);
val endTimeStr = (String)map.get("endTime");
val endTime = (endTimeStr != null) ?
OffsetDateTime.parse(endTimeStr, DATE_TIME_FORMATTER) : (OffsetDateTime)null;
val path = (String)map.getOrDefault("path", "/MISSING_PATH");
val existStatusMap = (Map<String, Object>)map.getOrDefault("exitStatus", emptyMap());
val exitDescription = (String)existStatusMap.getOrDefault("exitDescription", "");
val exitCode = (String)existStatusMap.getOrDefault("exitCode", "UNKNOWN");
val running = (Boolean)existStatusMap.getOrDefault("running", Boolean.FALSE);
val timeTaken = Long.valueOf(map.getOrDefault("timeTaken", -1L).toString());
val jcrNodesWritten = Long.parseLong(map.getOrDefault("jcrNodesWritten", -1L).toString());
return new JobStatus(uri, transactionId, jobExecutionId, startTime, endTime, path, timeTaken, jcrNodesWritten,
exitDescription, exitCode, running);
}