use of javax.annotation.Nullable in project buck by facebook.
the class SignatureFactory method getSignature.
/**
* Returns the type signature of the given element. If none is required by the VM spec, returns
* null.
*/
@Nullable
public String getSignature(Element element) {
SignatureWriter writer = new SignatureWriter();
element.accept(elementVisitorAdapter, writer);
String result = writer.toString();
return result.isEmpty() ? null : result;
}
use of javax.annotation.Nullable in project buck by facebook.
the class ProcessHelper method getProcessResourceConsumption.
/**
* Gets resource consumption of the process with the given pid.
*/
@Nullable
public ProcessResourceConsumption getProcessResourceConsumption(long pid) {
try {
OperatingSystem os = OSHI.getOperatingSystem();
OSProcess process = os.getProcess((int) pid);
return getProcessResourceConsumptionInternal(process);
} catch (Exception ex) {
// do nothing
return null;
}
}
use of javax.annotation.Nullable in project buck by facebook.
the class ProcessHelper method unixLikeProcessId.
@Nullable
private Long unixLikeProcessId(Object process) {
Class<?> clazz = process.getClass();
try {
if (clazz.getName().equals("java.lang.UNIXProcess")) {
Field field = clazz.getDeclaredField("pid");
field.setAccessible(true);
return (long) field.getInt(process);
}
} catch (Exception e) {
LOG.warn(e, "Cannot get process id!");
}
return null;
}
use of javax.annotation.Nullable in project buck by facebook.
the class Types method getContainerClass.
/**
* @return The raw type of the {@link Collection} a field represents, even if contained in an
* {@link Optional}, but without the ParameterizedType information.
*/
@SuppressWarnings("unchecked")
@Nullable
public static Class<? extends Collection<?>> getContainerClass(Field field) {
Type type = getFirstNonOptionalType(field);
if (!(type instanceof ParameterizedType)) {
return null;
}
Type rawType = ((ParameterizedType) type).getRawType();
if (!(rawType instanceof Class)) {
return null;
}
Class<?> clazz = (Class<?>) rawType;
if (!(Collection.class.isAssignableFrom(clazz))) {
return null;
}
return (Class<? extends Collection<?>>) clazz;
}
use of javax.annotation.Nullable in project buck by facebook.
the class FakeInputBasedRuleKeyFactory method newInstance.
private RuleKeyBuilder<RuleKey> newInstance(final BuildRule buildRule) {
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
SourcePathResolver resolver = new SourcePathResolver(ruleFinder);
return new RuleKeyBuilder<RuleKey>(ruleFinder, resolver, fileHashCache) {
@Override
protected RuleKeyBuilder<RuleKey> setBuildRule(BuildRule rule) {
return this;
}
@Override
protected RuleKeyBuilder<RuleKey> setReflectively(@Nullable Object val) {
return this;
}
@Override
public RuleKeyBuilder<RuleKey> setAppendableRuleKey(RuleKeyAppendable appendable) {
return this;
}
@Override
protected RuleKeyBuilder<RuleKey> setSourcePath(SourcePath sourcePath) {
return this;
}
@Override
protected RuleKeyBuilder<RuleKey> setNonHashingSourcePath(SourcePath sourcePath) {
return setNonHashingSourcePathDirectly(sourcePath);
}
@Override
public RuleKey build() {
if (oversized.contains(buildRule.getBuildTarget())) {
throw new SizeLimiter.SizeLimitException();
}
return ruleKeys.get(buildRule.getBuildTarget());
}
};
}
Aggregations