public Map<String, String> getDirectives() { return m_cap.getDirectives(); }
public Map<String, String> getDirectives() { return m_cap.getDirectives(); }
static boolean isSingleton(ModuleRevision revision) { List<Capability> identities = revision.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE); if (identities.isEmpty()) return false; return "true".equals(identities.get(0).getDirectives().get(IdentityNamespace.CAPABILITY_SINGLETON_DIRECTIVE)); //$NON-NLS-1$ }
static boolean isSingleton(ModuleRevision revision) { List<Capability> identities = revision.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE); if (identities.isEmpty()) return false; return "true".equals(identities.get(0).getDirectives().get(IdentityNamespace.CAPABILITY_SINGLETON_DIRECTIVE)); //$NON-NLS-1$ }
static boolean isSingleton(ModuleRevision revision) { List<Capability> identities = revision.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE); if (identities.isEmpty()) return false; return "true".equals(identities.get(0).getDirectives().get(IdentityNamespace.CAPABILITY_SINGLETON_DIRECTIVE)); //$NON-NLS-1$ }
@SuppressWarnings("unchecked") public static <T extends Capability> T as(final Capability cap, Class<T> type) { return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class<?>[] { type }, (target, method, args) -> (Capability.class == method.getDeclaringClass()) ? method.invoke(cap, args) : get(method, cap.getAttributes(), cap.getDirectives(), args)); }
@SuppressWarnings("unchecked") public static <T extends Capability> T as(final Capability cap, Class<T> type) { return (T) Proxy.newProxyInstance(type.getClassLoader(), new Class<?>[] { type }, (target, method, args) -> (Capability.class == method.getDeclaringClass()) ? method.invoke(cap, args) : get(method, cap.getAttributes(), cap.getDirectives(), args)); }
private boolean equalsCap(Capability 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 capability based on an existing capability, providing the resource. * The namespace, attributes and directives are copied from the provided capability. * @param capability The capability to base the new requirement on. * @param resource The resource to be associated with the capability */ public CapabilityImpl(Resource resource, Capability capability) { this(resource, capability.getNamespace(), capability.getDirectives(), capability.getAttributes()); }
/** * Create a capability based on an existing capability, providing the resource. * The namespace, attributes and directives are copied from the provided capability. * @param capability The capability to base the new requirement on. * @param resource The resource to be associated with the capability */ public CapabilityImpl(Resource resource, Capability capability) { this(resource, capability.getNamespace(), capability.getDirectives(), capability.getAttributes()); }
private static String createOSGiCapability(Capability cap) { Map<String, Object> attributes = new HashMap<String, Object>(cap.getAttributes()); Map<String, String> directives = cap.getDirectives(); String name = (String) attributes.remove(cap.getNamespace()); return name + ModuleRevision.toString(attributes, false, true) + ModuleRevision.toString(directives, true, true); }
private static String createOSGiCapability(Capability cap) { Map<String, Object> attributes = new HashMap<>(cap.getAttributes()); Map<String, String> directives = cap.getDirectives(); String name = (String) attributes.remove(cap.getNamespace()); return name + ModuleRevision.toString(attributes, false, true) + ModuleRevision.toString(directives, true, true); }
private static String createOSGiCapability(Capability cap) { Map<String, Object> attributes = new HashMap<String, Object>(cap.getAttributes()); Map<String, String> directives = cap.getDirectives(); String name = (String) attributes.remove(cap.getNamespace()); return name + ModuleRevision.toString(attributes, false, true) + ModuleRevision.toString(directives, true, true); }
public static String toProvideCapability(Capability capability) throws Exception { StringBuilder sb = new StringBuilder(); sb.append(capability.getNamespace()); CapReqBuilder r = new CapReqBuilder(capability.getNamespace()); r.addAttributes(capability.getAttributes()); r.addDirectives(capability.getDirectives()); Attrs attrs = r.toAttrs(); sb.append(";") .append(attrs); return sb.toString(); }
public CapReqBuilder from(Capability c) throws Exception { addAttributes(c.getAttributes()); addDirectives(c.getDirectives()); return this; }
public CapReqBuilder from(Capability c) throws Exception { addAttributes(c.getAttributes()); addDirectives(c.getDirectives()); return this; }
public static CapReqBuilder clone(Capability capability) throws Exception { CapabilityBuilder builder = new CapabilityBuilder(capability.getNamespace()); builder.addAttributes(capability.getAttributes()); builder.addDirectives(capability.getDirectives()); return builder; }
public static CapReqBuilder clone(Capability capability) { CapReqBuilder builder = new CapReqBuilder(capability.getNamespace()); builder.addAttributes(capability.getAttributes()); builder.addDirectives(capability.getDirectives()); return builder; }
public static CapReqBuilder clone(Capability capability) { CapReqBuilder builder = new CapReqBuilder(capability.getNamespace()); builder.addAttributes(capability.getAttributes()); builder.addDirectives(capability.getDirectives()); return builder; }
private List<GenericDescription> createProvideCapability(Capability capability) { Map<String, Object> attributes = capability.getAttributes(); Map<String, String> directives = capability.getDirectives(); String declaration = capability.getNamespace() + toString(attributes, "=", false) + toString(directives, ":=", true); //$NON-NLS-1$//$NON-NLS-2$ List<GenericDescription> result = state.getFactory().createGenericDescriptions(declaration); for (GenericDescription genericDescription : result) { genericDescription.setUserObject(capability); } return result; }