public static Node findOrCreateFirstChildWithAttributeValue(@Nullable Node root, String childName, String attribute, String value) { Node child = findFirstChildWithAttributeValue(root, childName, attribute, value); if (child == null) { Map<String, Object> attributes = Maps.newHashMap(); attributes.put(attribute, value); child = root.appendNode(childName, attributes); } return child; }
@Override public PersistentCache open(File cacheDir, String displayName, @Nullable CacheValidator cacheValidator, Map<String, ?> properties, CacheBuilder.LockTarget lockTarget, LockOptions lockOptions, Action<? super PersistentCache> initializer) throws CacheOpenException { lock.lock(); try { return doOpen(cacheDir, displayName, cacheValidator, properties, lockTarget, lockOptions, initializer); } finally { lock.unlock(); } }
@Nullable public static ScriptBlock detectScriptBlock(Statement statement, Predicate<? super ScriptBlock> predicate) { ScriptBlock scriptBlock = detectScriptBlock(statement); if (scriptBlock != null && predicate.apply(scriptBlock)) { return scriptBlock; } else { return null; } }
@Nullable public static ScriptBlock detectScriptBlock(Statement statement, final Collection<String> names) { return detectScriptBlock(statement, new Predicate<ScriptBlock>() { public boolean apply(ScriptBlock input) { return names.contains(input.getName()); } }); }
@Nullable protected <T extends ComponentSpec> T getComponentAs(Class<T> componentType) { if (componentNode == null) { return null; } ModelType<T> modelType = ModelType.of(componentType); return componentNode.canBeViewedAs(modelType) ? componentNode.asImmutable(modelType, componentNode.getDescriptor()).getInstance() : null; }
DefaultBinaryNamingScheme(@Nullable String parentName, @Nullable String binaryName, @Nullable String binaryType, @Nullable String role, boolean main, List<String> dimensions) { this.parentName = parentName; this.binaryName = binaryName; this.binaryType = binaryType; this.role = role; this.main = main; this.dimensions = dimensions; this.dimensionPrefix = createPrefix(dimensions); }
@Nullable private String defaultType() { File toSign = getToSign(); SignatureType signatureType = getSignatureType(); return toSign != null && signatureType != null ? signatureType.combinedExtension(toSign) : null; }
@Nullable @Override protected MetaProperty lookupProperty(MetaClass metaClass, String name) { MetaProperty metaProperty = super.lookupProperty(metaClass, name); if (metaProperty != null) { return metaProperty; } metaProperty = classMetaData.getMetaProperty(name); if (metaProperty != null && Modifier.isStatic(metaProperty.getModifiers())) { return metaProperty; } return null; }
public void applyRules(@Nullable String pluginId, Class<?> clazz) { ModelRegistry modelRegistry = target.getModelRegistry(); Iterable<Class<? extends RuleSource>> declaredSources = ruleDetector.getDeclaredSources(clazz); for (Class<? extends RuleSource> ruleSource : declaredSources) { ExtractedRuleSource<?> rules = ruleInspector.extract(ruleSource); for (Class<?> dependency : rules.getRequiredPlugins()) { target.getPluginManager().apply(dependency); } modelRegistry.getRoot().applyToSelf(rules); } }
public <T> ParameterizedRuleSource(List<ExtractedRuleDetails> rules, @Nullable ModelProperty<?> target, List<ModelProperty<?>> implicitInputs, StructSchema<T> schema, StructBindings<?> bindings, ManagedProxyFactory proxyFactory) { this.rules = rules; this.target = target; this.implicitInputs = implicitInputs; this.schema = schema; this.bindings = bindings; this.proxyFactory = proxyFactory; }
private <S extends T> void doCreate(String name, ModelType<S> type, @Nullable Action<? super S> initAction) { ModelPath childPath = modelNode.getPath().child(name); ModelRuleDescriptor descriptor = sourceDescriptor.append("create(%s)", name); if (initAction != null) { doCreate(childPath, type, descriptor, NoInputsModelAction.of(ModelReference.of(childPath, type), descriptor, initAction)); } else { doCreate(childPath, type, descriptor, null); } }
private Collection<ContextAwareTaskAction> transformToContextAwareTaskActions(Collection<Object> c) { return Collections2.transform(c, new Function<Object, ContextAwareTaskAction>() { public ContextAwareTaskAction apply(@Nullable Object input) { return wrap((Action<? super Task>) input); } }); }
@Override @Nullable public <S extends PUBLIC> ImplementationInfo getImplementationInfo(ModelType<S> publicType) { ImplementationRegistration<S> implementationRegistration = getImplementationRegistration(publicType); if (implementationRegistration == null) { return null; } return new ImplementationInfoImpl<S>(publicType, implementationRegistration, getInternalViews(publicType)); }
private VersionNumber(int major, int minor, int micro, int patch, @Nullable String qualifier, AbstractScheme scheme) { this.major = major; this.minor = minor; this.micro = micro; this.patch = patch; this.qualifier = qualifier; this.scheme = scheme; }
public void define(@Nullable Map<String, Object> args) { if (args == null) { return; } for (Map.Entry<String, Object> arg: args.entrySet()) { JavaReflectionUtil.writeableProperty(getClass(), arg.getKey()).setValue(this, arg.getValue()); } }
BeanDynamicObject(Object bean, @Nullable Class<?> publicType, boolean includeProperties, boolean implementsMissing, PropertySetTransformer propertySetTransformer, MethodArgumentsTransformer methodArgumentsTransformer) { if (bean == null) { throw new IllegalArgumentException("Value is null"); } this.bean = bean; this.publicType = publicType; this.includeProperties = includeProperties; this.implementsMissing = implementsMissing; this.propertySetTransformer = propertySetTransformer; this.argsTransformer = methodArgumentsTransformer; this.delegate = determineDelegate(bean); }
private static Function<String, Dependency> scopeToDependency(final IdeDependencyKey<?, Dependency> dependencyKey) { return new Function<String, Dependency>() { @Override @Nullable public Dependency apply(String s) { return dependencyKey.buildDependency(s); } }; }
private void printException(TestDescriptor descriptor, Throwable exception, @Nullable List<StackTraceElement> parentTrace, int exceptionLevel, StringBuilder builder) { String exceptionIndent = Strings.repeat(INDENT, exceptionLevel + 1); String exceptionText = exceptionLevel == 0 ? exception.toString() : "\nCaused by:\n" + exception.toString(); String indentedText = TextUtil.indent(exceptionText, exceptionIndent); builder.append(indentedText); builder.append('\n'); String stackTraceIndent = exceptionIndent + INDENT; List<StackTraceElement> stackTrace = null; if (testLogging.getShowStackTraces()) { stackTrace = filterStackTrace(exception, descriptor); int commonElements = countCommonElements(stackTrace, parentTrace); for (int i = 0; i < stackTrace.size() - commonElements; i++) { builder.append(stackTraceIndent); builder.append("at "); builder.append(stackTrace.get(i)); builder.append('\n'); } if (commonElements != 0) { builder.append(stackTraceIndent); builder.append("... "); builder.append(commonElements); builder.append(" more"); builder.append('\n'); } } if (testLogging.getShowCauses() && exception.getCause() != null) { printException(descriptor, exception.getCause(), stackTrace, exceptionLevel + 1, builder); } }
@Nullable public FileLock tryLock(RandomAccessFile lockFileAccess, boolean shared) throws IOException { try { return lockFileAccess.getChannel().tryLock(infoRegionPos, INFORMATION_REGION_SIZE - infoRegionPos, shared); } catch (OverlappingFileLockException e) { // Locked by the same process, treat as if locked by another process return null; } }
/** * Called from an object's {@link Configurable#configure} method. */ public static <T> T configureSelf(@Nullable Closure configureClosure, T target) { if (configureClosure == null) { return target; } configureTarget(configureClosure, target, new ConfigureDelegate(configureClosure, target)); return target; }
@Override public PersistentCache open(File cacheDir, String displayName, @Nullable CacheValidator cacheValidator, Map<String, ?> properties, CacheBuilder.LockTarget lockTarget, LockOptions lockOptions, Action<? super PersistentCache> initializer) throws CacheOpenException { GFileUtils.mkdirs(cacheDir); InMemoryCache cache = new InMemoryCache(cacheDir); if (initializer != null) { initializer.execute(cache); } return cache; }
@Nullable ModuleVersionResolveException getFailure();
public DefaultModuleComponentArtifactIdentifier(ModuleComponentIdentifier componentIdentifier, String name, String type, @Nullable String extension, @Nullable String classifier) { this(componentIdentifier, new DefaultIvyArtifactName(name, type, extension, classifier)); }
@Nullable @Override public File getFile() { return sourceFile; }
public UnsupportedNotationException(Object notation, String failure, @Nullable String resolution, Collection<String> candidateTypes) { super(format(failure, resolution, candidateTypes)); this.notation = notation; }
@Nullable private String fileName() { final File file = getFile(); return file != null ? file.getName() : null; }
@Nullable public String getShortDescription() { return shortDescription; }
@Override @Nullable public ComponentSpec getComponent() { return getComponentAs(ComponentSpec.class); }
protected static @Nullable <T> List<T> rationalizeInput(@Nullable Iterable<? extends T> arguments) { return arguments != null && arguments.iterator().hasNext() ? CollectionUtils.toList(arguments) : null; }
public void endOfStream(@Nullable Throwable failure) { CloseInput message = new CloseInput(); LOGGER.debug("Dispatching close input message: {}", message); dispatch.dispatch(message); }
@Nullable public PropertyMetaData getProperty(String name) { return properties.get(name); }
@Override public BinaryNamingScheme withBinaryName(@Nullable String name) { return new DefaultBinaryNamingScheme(parentName, name, binaryType, role, main, dimensions); }
/** * The parent for the operation, if any. When null, the operation of the current thread is used. */ @Nullable public BuildOperationExecutor.Operation getParent() { return parent; }
@Override @Nullable public String getVersion() { return version; }
@Nullable @Override public Object getOwnerBuildOperationId() { return testTaskOperationId; }
@Nullable ComponentSpec getComponent();
@Nullable <T extends DependentBinariesResolutionStrategy> T getStrategy(String name, Class<T> type);
@Nullable @Override protected List<DependentBinariesResolvedResult> resolveDependents(BinarySpecInternal target) { return null; }
@Nullable @Override public Object getOwnerBuildOperationId() { return null; }
@Nullable protected MetaMethod lookupMethod(MetaClass metaClass, String name, Class[] arguments) { return metaClass.getMetaMethod(name, arguments); }