public static boolean isDynamic(Requirement req) { return PackageNamespace.RESOLUTION_DYNAMIC.equals(req.getDirectives() .get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE)); }
public static boolean isReexport(Requirement req) { return BundleNamespace.VISIBILITY_REEXPORT.equals(req.getDirectives() .get(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE)); }
public static boolean isOptional(Requirement req) { String resolution = req.getDirectives().get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE); return Namespace.RESOLUTION_OPTIONAL.equalsIgnoreCase(resolution); }
@Override public boolean isEffective(Requirement requirement) { String effective = requirement.getDirectives().get(Namespace.REQUIREMENT_EFFECTIVE_DIRECTIVE); return effective == null || Namespace.EFFECTIVE_RESOLVE.equals(effective); }
@Override public boolean isEffective(Requirement requirement) { String effective = requirement.getDirectives().get(Namespace.REQUIREMENT_EFFECTIVE_DIRECTIVE); return effective == null || Namespace.EFFECTIVE_RESOLVE.equals(effective); }
public static boolean isOptional(Requirement req) { String resolution = req.getDirectives().get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE); return Namespace.RESOLUTION_OPTIONAL.equalsIgnoreCase(resolution); }
public static boolean isDynamic(Requirement req) { return PackageNamespace.RESOLUTION_DYNAMIC.equals(req.getDirectives() .get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE)); }
public static ResolutionDirective getResolution(Requirement requirement) { String resolution = requirement.getDirectives() .get(Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE); if (resolution == null || resolution.equals(Namespace.RESOLUTION_MANDATORY)) return ResolutionDirective.mandatory; if (resolution.equals(Namespace.RESOLUTION_OPTIONAL)) return ResolutionDirective.optional; return null; }
private static void copyDirectives(Requirement req, CapReqBuilder builder, Set<String> excludes) throws Exception { for (Entry<String, String> entry : req.getDirectives() .entrySet()) { if (!excludes.contains(entry.getKey())) builder.addDirective(entry.getKey(), entry.getValue()); } }
public static boolean isMultiple(Requirement req) { return Namespace.CARDINALITY_MULTIPLE.equals(req.getDirectives() .get(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE)) && !isDynamic(req); }
public static boolean isMultiple(Requirement req) { return Namespace.CARDINALITY_MULTIPLE.equals(req.getDirectives() .get(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE)) && !isDynamic(req); }
public Expression parse(Requirement req) { String f = req.getDirectives() .get("filter"); if (f == null) return Expression.FALSE; return parse(f); }
public static boolean isMultiple(Requirement req) { return Namespace.CARDINALITY_MULTIPLE.equals(req.getDirectives() .get(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE)) && !isDynamic(req); }
@SuppressWarnings("unchecked") public static <T extends Requirement> T as(final Requirement req, Class<T> type) { return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class<?>[] { type }, (target, method, args) -> (Requirement.class == method.getDeclaringClass()) ? method.invoke(req, args) : get(method, req.getAttributes(), req.getDirectives(), args)); }
private boolean equalsReq(Requirement other) { if (!Objects.equals(namespace, other.getNamespace())) return false; if (!Objects.equals(attributes, other.getAttributes())) return false; if (!Objects.equals(directives, other.getDirectives())) return false; return Objects.equals(resource, other.getResource()); }
/** * Create a requirement based on an existing requirement, providing the resource. * The namespace, attributes and directives are copied from the provided requirement. * @param requirement The requirement to base the new requirement on. * @param resource The resource to be associated with the requirement */ public RequirementImpl(Resource resource, Requirement requirement) { this(resource, requirement.getNamespace(), requirement.getDirectives(), requirement.getAttributes()); }
public static String toRequireCapability(Requirement requirement) throws Exception { StringBuilder sb = new StringBuilder(); sb.append(requirement.getNamespace()); CapReqBuilder r = new CapReqBuilder(requirement.getNamespace()); r.addAttributes(requirement.getAttributes()); r.addDirectives(requirement.getDirectives()); Attrs attrs = r.toAttrs(); sb.append(";") .append(attrs); return sb.toString(); }
public CapReqBuilder from(Requirement r) throws Exception { addAttributes(r.getAttributes()); addDirectives(r.getDirectives()); return this; }
public static CapReqBuilder clone(Requirement requirement) throws Exception { RequirementBuilder builder = new RequirementBuilder(requirement.getNamespace()); builder.addAttributes(requirement.getAttributes()); builder.addDirectives(requirement.getDirectives()); return builder; }
public static CapReqBuilder clone(Requirement requirement) throws Exception { RequirementBuilder builder = new RequirementBuilder(requirement.getNamespace()); builder.addAttributes(requirement.getAttributes()); builder.addDirectives(requirement.getDirectives()); return builder; }