private static void copyAttribs(Requirement req, CapReqBuilder builder, Set<String> excludes) throws Exception { for (Entry<String, Object> entry : req.getAttributes() .entrySet()) { if (!excludes.contains(entry.getKey())) builder.addAttribute(entry.getKey(), entry.getValue()); } }
private static void copyAttribs(Requirement req, CapReqBuilder builder, Set<String> excludes) throws Exception { for (Entry<String, Object> entry : req.getAttributes() .entrySet()) { if (!excludes.contains(entry.getKey())) builder.addAttribute(entry.getKey(), entry.getValue()); } }
public String convert(Requirement req) throws IllegalArgumentException { StringBuilder builder = new StringBuilder(); builder.append(req.getNamespace()); for (Entry<String,String> directive : req.getDirectives().entrySet()) { builder.append(';').append(directive.getKey()).append(":='").append(directive.getValue()).append('\''); } for (Entry<String,Object> attribute : req.getAttributes().entrySet()) { builder.append(';').append(attribute.getKey()).append("='").append(attribute.getValue()).append('\''); } return builder.toString(); }
public String convert(Requirement req) throws IllegalArgumentException { StringBuilder builder = new StringBuilder(); builder.append(req.getNamespace()); for (Entry<String,String> directive : req.getDirectives().entrySet()) { builder.append(';').append(directive.getKey()).append(":='").append(directive.getValue()).append('\''); } for (Entry<String,Object> attribute : req.getAttributes().entrySet()) { builder.append(';').append(attribute.getKey()).append("='").append(attribute.getValue()).append('\''); } return builder.toString(); }
@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)); }
protected void addRequirement(String requirement) throws BundleException { for (Requirement req : ResourceBuilder.parseRequirement(this, requirement)) { Object range = req.getAttributes().get(CAPABILITY_VERSION_ATTRIBUTE); if (range instanceof String) { req.getAttributes().put(CAPABILITY_VERSION_ATTRIBUTE, new VersionRange((String) range)); } addRequirement(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)); }
static Requirement getSubsystemRequirement(Resource resource) { for (Requirement requirement : resource.getRequirements(null)) { if (IDENTITY_NAMESPACE.equals(requirement.getNamespace()) && TYPE_SUBSYSTEM.equals(requirement.getAttributes().get(CAPABILITY_TYPE_ATTRIBUTE))) { return requirement; } } return null; }
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()); }
/** * 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 CapReqBuilder from(Requirement r) throws Exception { addAttributes(r.getAttributes()); addDirectives(r.getDirectives()); return this; }
private Requirement negateRequirement(Requirement req) { String filter = req.getDirectives().get("filter"); if (filter == null) { throw new IllegalStateException("No filter directive: " + req); } String invFilter = "(!" + filter + ")"; return newRequirementBuilder(req.getNamespace()).setAttributes(req.getAttributes()) .setDirectives(req.getDirectives()).addDirective("filter", invFilter).build(); }
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; }
public static CapReqBuilder clone(Requirement requirement) { CapReqBuilder builder = new CapReqBuilder(requirement.getNamespace()); builder.addAttributes(requirement.getAttributes()); builder.addDirectives(requirement.getDirectives()); return builder; }
public static CapReqBuilder clone(Requirement requirement) { CapReqBuilder builder = new CapReqBuilder(requirement.getNamespace()); builder.addAttributes(requirement.getAttributes()); builder.addDirectives(requirement.getDirectives()); return builder; }
public static CapReqBuilder clone(Requirement requirement) { CapReqBuilder builder = new CapReqBuilder(requirement.getNamespace()); builder.addAttributes(requirement.getAttributes()); builder.addDirectives(requirement.getDirectives()); return builder; }