com.github.easypack.platform.Platform Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of easypack-maven-plugin Show documentation
Show all versions of easypack-maven-plugin Show documentation
Maven plugin for building Java applications in tar, zip and tar.gz format.
The newest version!
package com.github.easypack.platform;
import java.util.Collection;
import java.util.LinkedList;
/**
* Models the project targeted platform (operating system).
*
* @author agusmunioz
*
*/
public enum Platform {
WINDOWS {
@Override
public T behave(PlatformBehavioural behavioural) {
return behavioural.windows();
}
},
LINUX {
@Override
public T behave(PlatformBehavioural behavioural) {
return behavioural.linux();
}
};
/**
* Triggers a behavior based on the specific platform.
*
* @param behavioural
* the one interested in behaving based on the platform.
*
* @return the result of behaving based on the platform.
*/
public abstract T behave(PlatformBehavioural behavioural);
/**
* Gets a list of {@link Platform} using a comma separated string.
*
* @param platforms
* a comma separated list of platforms.
*
* @return the list of {@link Platform}.
*
* @throws IllegalArgumentException
* if a not supported platform name is provided.
*/
public static Collection fromString(String platforms) {
Collection mapped = new LinkedList();
String[] selected = platforms.split(",");
for (String platform : selected) {
try {
mapped.add(Platform.valueOf(platform.trim().toUpperCase()));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Unsupported platform: "
+ platform + ". Supported: linux, windows");
}
}
return mapped;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy