}
return environment;
}
public static EnvironmentType buildEnvironmentType(Environment environment) {
EnvironmentType environmentType = EnvironmentType.Factory.newInstance();
if (environment.getConfigId() != null) {
ArtifactType configId = toArtifactType(environment.getConfigId());
environmentType.setModuleId(configId);
}
List<DependencyType> dependencies = toDependencyTypes(environment.getDependencies());
DependencyType[] dependencyTypes = dependencies.toArray(new DependencyType[dependencies.size()]);
DependenciesType dependenciesType = environmentType.addNewDependencies();
dependenciesType.setDependencyArray(dependencyTypes);
if (environment.getBundleActivator() != null) {
environmentType.setBundleActivator(environment.getBundleActivator());
}
for (String bundleClassPath: environment.getBundleClassPath()) {
environmentType.addBundleClassPath(bundleClassPath);
}
for (String importPackage: environment.getImportPackages()) {
environmentType.addImportPackage(importPackage);
}
for (String exportPackage: environment.getExportPackages()) {
environmentType.addExportPackage(exportPackage);
}
for (String requireBundle : environment.getRequireBundles()) {
environmentType.addRequireBundle(requireBundle);
}
for (String dynamicImportPackage: environment.getDynamicImportPackages()) {
environmentType.addDynamicImportPackage(dynamicImportPackage);
}
ClassLoadingRules classLoadingRules = environment.getClassLoadingRules();
if (classLoadingRules.isInverseClassLoading()) {
environmentType.addNewInverseClassloading();
}
if (environment.isSuppressDefaultEnvironment()) {
environmentType.addNewSuppressDefaultEnvironment();
}
ClassLoadingRule classLoadingRule = classLoadingRules.getHiddenRule();
environmentType.setHiddenClasses(toFilterType(classLoadingRule.getClassPrefixes()));
classLoadingRule = classLoadingRules.getNonOverrideableRule();
environmentType.setNonOverridableClasses(toFilterType(classLoadingRule.getClassPrefixes()));
classLoadingRule = classLoadingRules.getPrivateRule();
environmentType.setPrivateClasses(toFilterType(classLoadingRule.getClassPrefixes()));
return environmentType;
}