private static CapabilityResponseResource asCapabilityResponseResource( final CCapability capability) { assert capability != null : "Capability cannot be null"; final CapabilityResource resource = new CapabilityResource(); resource.setId(capability.getId()); resource.setName(capability.getName()); resource.setTypeId(capability.getTypeId()); if (capability.getProperties() != null) { for (final CCapabilityProperty propery : capability.getProperties()) { final CapabilityPropertyResource resourceProp = new CapabilityPropertyResource(); resourceProp.setKey(propery.getKey()); resourceProp.setValue(propery.getValue()); resource.addProperty(resourceProp); } } final CapabilityResponseResource response = new CapabilityResponseResource(); response.setData(resource); return response; }
static CCapability asCCapability(final CapabilityResource resource) { assert resource != null : "Resource cannot be null"; final CCapability capability = new CCapability(); capability.setId(resource.getId()); capability.setName(resource.getName()); capability.setTypeId(resource.getTypeId()); if (resource.getProperties() != null) { for (final CapabilityPropertyResource propery : resource.getProperties()) { final CCapabilityProperty capabilityProp = new CCapabilityProperty(); capabilityProp.setKey(propery.getKey()); capabilityProp.setValue(propery.getValue()); capability.addProperty(capabilityProp); } } return capability; }