com.arm.mbed.cloud.sdk.accountmanagement.adapters.PolicyAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mbed-cloud-sdk Show documentation
Show all versions of mbed-cloud-sdk Show documentation
The Pelion Cloud SDK (formerly known as Mbed Cloud SDK) provides a simplified interface to the Pelion Cloud APIs by exposing functionality using conventions and paradigms familiar to Java developers.
package com.arm.mbed.cloud.sdk.accountmanagement.adapters;
import java.util.List;
import com.arm.mbed.cloud.sdk.accountmanagement.model.Policy;
import com.arm.mbed.cloud.sdk.annotations.Internal;
import com.arm.mbed.cloud.sdk.annotations.Preamble;
import com.arm.mbed.cloud.sdk.common.GenericAdapter;
import com.arm.mbed.cloud.sdk.common.GenericAdapter.Mapper;
import com.arm.mbed.cloud.sdk.common.TranslationUtils;
import com.arm.mbed.cloud.sdk.internal.iam.model.FeaturePolicy;
@Preamble(description = "Adapter for policy model")
@Internal
public final class PolicyAdapter {
private PolicyAdapter() {
super();
}
/**
* Maps policy objects.
*
* @param featurePolicy
* featurePolicy.
* @return a policy.
*/
public static Policy map(FeaturePolicy featurePolicy) {
if (featurePolicy == null) {
return null;
}
return new Policy(featurePolicy.getAction(), featurePolicy.getResource(), featurePolicy.getFeature(),
TranslationUtils.toBool(featurePolicy.isAllow(), false));
}
/**
* Gets a mapper.
*
* @return a mapper for this policy.
*/
public static Mapper getMapper() {
return new Mapper() {
@Override
public Policy map(FeaturePolicy toBeMapped) {
return PolicyAdapter.map(toBeMapped);
}
};
}
/**
* Maps a list of policies.
*
* @param list
* policies list
* @return list of policies
*/
public static List mapList(List list) {
return GenericAdapter.mapList(list, getMapper());
}
}