void setCapabilities(List<Capability> capabilities) { allCapabilities = capabilities; capabilityMap = new HashMap<String, List<Capability>>(); for (Capability capability : capabilities) { List<Capability> list = capabilityMap.get(capability.getNamespace()); if (list == null) { list = new LinkedList<Capability>(); capabilityMap.put(capability.getNamespace(), list); } list.add(capability); } }
@Override public String toString() { final StringBuilder builder = new StringBuilder(); List<Capability> identities = getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE); if (identities != null && identities.size() == 1) { Capability idCap = identities.get(0); Object id = idCap.getAttributes().get(IdentityNamespace.IDENTITY_NAMESPACE); Object version = idCap.getAttributes().get(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE); builder.append(id).append(" ver=").append(version); } else { // Generic toString builder.append("ResourceImpl [caps="); builder.append(allCapabilities); builder.append(", reqs="); builder.append(allRequirements); builder.append("]"); } return builder.toString(); }