下面列出了怎么用java.util.EnumMap的API类实例代码及写法,或者点击链接到github查看源代码。
private RelativeDateTimeFormatter(
EnumMap<Style, EnumMap<AbsoluteUnit, EnumMap<Direction, String>>> qualitativeUnitMap,
EnumMap<Style, EnumMap<RelativeUnit, String[][]>> patternMap,
String combinedDateAndTime,
PluralRules pluralRules,
NumberFormat numberFormat,
Style style,
DisplayContext capitalizationContext,
BreakIterator breakIterator,
ULocale locale) {
this.qualitativeUnitMap = qualitativeUnitMap;
this.patternMap = patternMap;
this.combinedDateAndTime = combinedDateAndTime;
this.pluralRules = pluralRules;
this.numberFormat = numberFormat;
this.style = style;
if (capitalizationContext.type() != DisplayContext.Type.CAPITALIZATION) {
throw new IllegalArgumentException(capitalizationContext.toString());
}
this.capitalizationContext = capitalizationContext;
this.breakIterator = breakIterator;
this.locale = locale;
this.dateFormatSymbols = new DateFormatSymbols(locale);
}
@NonNull
private List<Entry> search(double lat, double lng) throws SQLException {
EnumMap<Source, Entry> map = new EnumMap<>(Source.class);
for (Source source : Source.values()) {
if (source.citiesId == 0) continue;
CitiesSet entries = new CitiesSet(source);
for (Entry entry : entries) {
if (entry == null || entry.getKey() == null) continue;
Source s = entry.getSource();
Entry e = map.get(s);
double latDist = Math.abs(lat - entry.getLat());
double lngDist = Math.abs(lng - entry.getLng());
if (e == null) {
if (latDist < 2 && lngDist < 2)
map.put(s, (Entry) entry.clone());
} else {
if (latDist + lngDist < Math.abs(lat - e.getLat()) + Math.abs(lng - e.getLng())) {
map.put(s, (Entry) entry.clone());
}
}
}
}
return new ArrayList<>(map.values());
}
private EnumMap<UserAnnotationTag.Type, JCheckBox> createTypeCheckBoxes() {
EnumMap<UserAnnotationTag.Type, JCheckBox> map = new EnumMap<>(UserAnnotationTag.Type.class);
for (UserAnnotationTag.Type type : UserAnnotationTag.Type.values()) {
JCheckBox checkBox;
switch (type) {
case FUNCTION:
checkBox = functionCheckBox;
break;
case TYPE:
checkBox = typeCheckBox;
break;
case METHOD:
checkBox = methodCheckBox;
break;
case FIELD:
checkBox = fieldCheckBox;
break;
default:
throw new IllegalStateException("Unknown type: " + type);
}
map.put(type, checkBox);
}
return map;
}
/**
* @param booleanDataStyle the style for booleans
* @param currencyDataStyle the style for currencies
* @param dateDataStyle the style for dates
* @param floatDataStyle the style for numbers
* @param percentageDataStyle the style for percentages
* @param timeDataStyle the style for times
*/
public DataStyles(final BooleanStyle booleanDataStyle, final CurrencyStyle currencyDataStyle,
final DateStyle dateDataStyle, final FloatStyle floatDataStyle,
final PercentageStyle percentageDataStyle, final TimeStyle timeDataStyle) {
if (booleanDataStyle == null || currencyDataStyle == null || dateDataStyle == null ||
floatDataStyle == null || percentageDataStyle == null || timeDataStyle == null) {
throw new IllegalArgumentException();
}
this.booleanDataStyle = booleanDataStyle;
this.currencyDataStyle = currencyDataStyle;
this.dateDataStyle = dateDataStyle;
this.floatDataStyle = floatDataStyle;
this.percentageDataStyle = percentageDataStyle;
this.timeDataStyle = timeDataStyle;
this.dataStyleByType = new EnumMap<CellType, DataStyle>(CellType.class);
this.dataStyleByType.put(CellType.BOOLEAN, this.booleanDataStyle);
this.dataStyleByType.put(CellType.CURRENCY, this.currencyDataStyle);
this.dataStyleByType.put(CellType.DATE, this.dateDataStyle);
this.dataStyleByType.put(CellType.FLOAT, this.floatDataStyle);
this.dataStyleByType.put(CellType.PERCENTAGE, this.percentageDataStyle);
this.dataStyleByType.put(CellType.TIME, this.timeDataStyle);
}
@NonNull
private List<Entry> search(double lat, double lng) throws SQLException {
EnumMap<Source, Entry> map = new EnumMap<>(Source.class);
for (Source source : Source.values()) {
if (source.citiesId == 0) continue;
CitiesSet entries = new CitiesSet(source);
for (Entry entry : entries) {
if (entry == null || entry.getKey() == null) continue;
Source s = entry.getSource();
Entry e = map.get(s);
double latDist = Math.abs(lat - entry.getLat());
double lngDist = Math.abs(lng - entry.getLng());
if (e == null) {
if (latDist < 2 && lngDist < 2)
map.put(s, (Entry) entry.clone());
} else {
if (latDist + lngDist < Math.abs(lat - e.getLat()) + Math.abs(lng - e.getLng())) {
map.put(s, (Entry) entry.clone());
}
}
}
}
return new ArrayList<>(map.values());
}
/**
* <pre>
* name : THICKNESS
* attributes : THICKNESSAttribute { VALUE!, START, STARTOPEN, END, ENDOPEN }
* structure : SPELLS ?
* </pre>
*/
private void __thickness(final String edgeId) throws IOException, XMLStreamException {
XMLEvent e;
EnumMap<THICKNESSAttribute, String> attributes;
e = getNextEvent();
checkValid(e, XMLEvent.START_ELEMENT, "thickness");
attributes = getAttributes(THICKNESSAttribute.class, e.asStartElement());
checkRequiredAttributes(e, attributes, THICKNESSAttribute.VALUE);
e = getNextEvent();
if (isEvent(e, XMLEvent.START_ELEMENT, "spells")) {
pushback(e);
__spells();
e = getNextEvent();
}
checkValid(e, XMLEvent.END_ELEMENT, "thickness");
}
public static void main(String[] args) throws Exception {
final EnumMap<TestEnum, String> enumMap = new EnumMap<>(TestEnum.class);
for (TestEnum e : TestEnum.values()) {
enumMap.put(e, e.name());
}
Set<Map.Entry<TestEnum, String>> entrySet = enumMap.entrySet();
HashSet<Map.Entry<TestEnum, String>> hashSet = new HashSet<>(entrySet);
if (false == hashSet.equals(entrySet)) {
throw new RuntimeException("Test FAILED: Sets are not equal.");
}
if (hashSet.hashCode() != entrySet.hashCode()) {
throw new RuntimeException("Test FAILED: Set's hashcodes are not equal.");
}
}
@Test
public void givenPizaOrders_whenGroupByStatusCalled_thenCorrectlyGrouped() {
List<Pizza> pzList = new ArrayList<>();
Pizza pz1 = new Pizza();
pz1.setStatus(Pizza.PizzaStatusEnum.DELIVERED);
Pizza pz2 = new Pizza();
pz2.setStatus(Pizza.PizzaStatusEnum.ORDERED);
Pizza pz3 = new Pizza();
pz3.setStatus(Pizza.PizzaStatusEnum.ORDERED);
Pizza pz4 = new Pizza();
pz4.setStatus(Pizza.PizzaStatusEnum.READY);
pzList.add(pz1);
pzList.add(pz2);
pzList.add(pz3);
pzList.add(pz4);
EnumMap<Pizza.PizzaStatusEnum, List<Pizza>> map = Pizza.groupPizzaByStatus(pzList);
assertTrue(map.get(Pizza.PizzaStatusEnum.DELIVERED).size() == 1);
assertTrue(map.get(Pizza.PizzaStatusEnum.ORDERED).size() == 2);
assertTrue(map.get(Pizza.PizzaStatusEnum.READY).size() == 1);
}
@Override
protected Collection< GeneralStats< ExpansionLevel > > calculateStats( final PlayerStats playerStats ) {
// Calculate stats
final Map< ExpansionLevel, GeneralStats< ExpansionLevel > > generalStatsMap = new EnumMap<>( ExpansionLevel.class );
for ( final Game g : playerStats.gameList )
for ( final Part refPart : g.parts ) { // Have to go through all participants as the zero-toon might be present multiple times
if ( !playerStats.obj.equals( refPart.toon ) )
continue;
GeneralStats< ExpansionLevel > gs = generalStatsMap.get( g.expansion );
if ( gs == null )
generalStatsMap.put( g.expansion, gs = new GeneralStats<>( g.expansion ) );
gs.updateWithPartGame( refPart, g );
}
return generalStatsMap.values();
}
private WrodlPartyService() {
try {
try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET party = -1, fatigue = 0")) {
ps.executeUpdate();
ps.close();
}
} catch (SQLException e) {
FileoutputUtil.log("更新角色组队为-1失败");
}
this.runningPartyId = new AtomicInteger(1);
this.runningExpedId = new AtomicInteger(1);
this.partyList = new HashMap();
this.expedsList = new HashMap();
this.searcheList = new EnumMap(PartySearchType.class);
for (PartySearchType pst : PartySearchType.values()) {
this.searcheList.put(pst, new ArrayList());
}
}
public ParentBlockHeaderValidator createUnityParentBlockHeaderValidator() {
List<DependentBlockHeaderRule> PoWrules =
Arrays.asList(
new BlockNumberRule(),
new ParentOppositeTypeRule(),
new TimeStampRule(),
new EnergyLimitRule(
getConstants().getEnergyDivisorLimitLong(),
getConstants().getEnergyLowerBoundLong()));
List<DependentBlockHeaderRule> PoSrules =
Arrays.asList(
new BlockNumberRule(),
new ParentOppositeTypeRule(),
new StakingBlockTimeStampRule(),
new TimeStampRule(),
new EnergyLimitRule(
getConstants().getEnergyDivisorLimitLong(),
getConstants().getEnergyLowerBoundLong()));
Map<Seal, List<DependentBlockHeaderRule>> unityRules = new EnumMap<>(Seal.class);
unityRules.put(Seal.PROOF_OF_WORK, PoWrules);
unityRules.put(Seal.PROOF_OF_STAKE, PoSrules);
return new ParentBlockHeaderValidator(unityRules);
}
void initHandlers() {
handlersForLocation = new HashMap<Location, LocationHandler>();
handlersForOption = new EnumMap<Option, LocationHandler>(Option.class);
LocationHandler[] handlers = {
new BootClassPathLocationHandler(),
new ClassPathLocationHandler(),
new SimpleLocationHandler(StandardLocation.SOURCE_PATH, Option.SOURCEPATH),
new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, Option.PROCESSORPATH),
new OutputLocationHandler((StandardLocation.CLASS_OUTPUT), Option.D),
new OutputLocationHandler((StandardLocation.SOURCE_OUTPUT), Option.S),
new OutputLocationHandler((StandardLocation.NATIVE_HEADER_OUTPUT), Option.H)
};
for (LocationHandler h: handlers) {
handlersForLocation.put(h.location, h);
for (Option o: h.options)
handlersForOption.put(o, h);
}
}
public BgpProcess(long procnum) {
_afGroups = new HashMap<>();
_aggregateNetworks = new HashMap<>();
_aggregateIpv6Networks = new HashMap<>();
_allPeerGroups = new HashSet<>();
_defaultIpv4Activate = true;
_dynamicIpPeerGroups = new HashMap<>();
_dynamicIpv6PeerGroups = new HashMap<>();
_namedPeerGroups = new HashMap<>();
_ipNetworks = new LinkedHashMap<>();
_ipPeerGroups = new HashMap<>();
_ipv6Networks = new LinkedHashMap<>();
_ipv6PeerGroups = new HashMap<>();
_peerSessions = new HashMap<>();
_procnum = procnum;
_redistributionPolicies = new EnumMap<>(RoutingProtocol.class);
_masterBgpPeerGroup = new MasterBgpPeerGroup();
_masterBgpPeerGroup.setAdvertiseInactive(true);
_masterBgpPeerGroup.setDefaultMetric(DEFAULT_BGP_DEFAULT_METRIC);
}
void initHandlers() {
handlersForLocation = new HashMap<Location, LocationHandler>();
handlersForOption = new EnumMap<Option, LocationHandler>(Option.class);
LocationHandler[] handlers = {
new BootClassPathLocationHandler(),
new ClassPathLocationHandler(),
new SimpleLocationHandler(StandardLocation.SOURCE_PATH, Option.SOURCEPATH),
new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, Option.PROCESSORPATH),
new OutputLocationHandler((StandardLocation.CLASS_OUTPUT), Option.D),
new OutputLocationHandler((StandardLocation.SOURCE_OUTPUT), Option.S),
new OutputLocationHandler((StandardLocation.NATIVE_HEADER_OUTPUT), Option.H)
};
for (LocationHandler h: handlers) {
handlersForLocation.put(h.location, h);
for (Option o: h.options)
handlersForOption.put(o, h);
}
}
public static Vector<Units> getCompatibleUnits(Units selected) {
if((groups == null) || (groupMap == null)) {
groups = new Vector[5];
groups[0] = new Vector<Units>(Arrays.asList(new Units[]{Units.PIXEL, Units.NANOMETER, Units.MICROMETER}));
groups[1] = new Vector<Units>(Arrays.asList(new Units[]{Units.PIXEL_SQUARED, Units.NANOMETER_SQUARED, Units.MICROMETER_SQUARED}));
groups[2] = new Vector<Units>(Arrays.asList(new Units[]{Units.DIGITAL, Units.PHOTON}));
groups[3] = new Vector<Units>(Arrays.asList(new Units[]{Units.DEGREE, Units.RADIAN}));
groups[4] = new Vector<Units>(Arrays.asList(new Units[]{Units.UNITLESS}));
//
groupMap = new EnumMap<Units, Integer>(Units.class);
groupMap.put(Units.PIXEL, 0);
groupMap.put(Units.NANOMETER, 0);
groupMap.put(Units.MICROMETER, 0);
groupMap.put(Units.PIXEL_SQUARED, 1);
groupMap.put(Units.NANOMETER_SQUARED, 1);
groupMap.put(Units.MICROMETER_SQUARED, 1);
groupMap.put(Units.DIGITAL, 2);
groupMap.put(Units.PHOTON, 2);
groupMap.put(Units.DEGREE, 3);
groupMap.put(Units.RADIAN, 3);
groupMap.put(Units.UNITLESS, 4);
}
return groups[groupMap.get(selected)];
}
public static void main(String[] args) {
// 测试 PayrollDay (策略枚举)
System.out.println("时薪100的人在周五工作8小时的收入:" + PayrollDay.FRIDAY.pay(8.0, 100));
System.out.println("时薪100的人在周六工作8小时的收入:" + PayrollDay.SATURDAY.pay(8.0, 100));
// EnumSet的使用
System.out.println("EnumSet展示");
EnumSet<ErrorCodeEn> errSet = EnumSet.allOf(ErrorCodeEn.class);
for (ErrorCodeEn e : errSet) {
System.out.println(e.name() + " : " + e.ordinal());
}
// EnumMap的使用
System.out.println("EnumMap展示");
EnumMap<StateMachineDemo.Signal, String> errMap = new EnumMap(StateMachineDemo.Signal.class);
errMap.put(StateMachineDemo.Signal.RED, "红灯");
errMap.put(StateMachineDemo.Signal.YELLOW, "黄灯");
errMap.put(StateMachineDemo.Signal.GREEN, "绿灯");
for (Iterator<Map.Entry<StateMachineDemo.Signal, String>> iter = errMap.entrySet().iterator(); iter
.hasNext(); ) {
Map.Entry<StateMachineDemo.Signal, String> entry = iter.next();
System.out.println(entry.getKey().name() + " : " + entry.getValue());
}
}
private EnumMap<Planet, Double> calcNatonnataBala() {
double btimeDeg = SwissHelper.calcNatonnataBalaDeg(birthData.birthSD(),
birthData.birthTime());
EnumMap<Planet, Double> NatonnataBala = new EnumMap<Planet, Double>(
Planet.class);
NatonnataBala.put(Planet.Sun, btimeDeg / 3);
NatonnataBala.put(Planet.Jupiter, btimeDeg / 3);
NatonnataBala.put(Planet.Venus, btimeDeg / 3);
NatonnataBala.put(Planet.Moon, ((180 - btimeDeg) / 3));
NatonnataBala.put(Planet.Mars, ((180 - btimeDeg) / 3));
NatonnataBala.put(Planet.Saturn, ((180 - btimeDeg) / 3));
NatonnataBala.put(Planet.Mercury, 60.0);
return NatonnataBala;
// System.out.println("\nbt : " + birthData.birthTime() + " E: " +
// AstroUtil.dms(EqnOfTime) + sbErr);
}
/**
* Test to verify that the experimental command will not be executed if
* {@link IgniteSystemProperties#IGNITE_ENABLE_EXPERIMENTAL_COMMAND} =
* {@code false}, a warning will be displayed instead.
* */
@Test
@WithSystemProperty(key = IGNITE_ENABLE_EXPERIMENTAL_COMMAND, value = "false")
public void testContainsWarnInsteadExecExperimentalCmdWhenEnableExperimentalFalse() {
injectTestSystemOut();
Map<CommandList, Collection<String>> cmdArgs = new EnumMap<>(CommandList.class);
cmdArgs.put(WAL, asList("print", "delete"));
cmdArgs.put(METADATA, asList("help", "list"));
String warning = String.format(
"For use experimental command add %s=true to JVM_OPTS in %s",
IGNITE_ENABLE_EXPERIMENTAL_COMMAND,
UTILITY_NAME
);
stream(CommandList.values()).filter(cmd -> cmd.command().experimental())
.peek(cmd -> assertTrue("Not contains " + cmd, cmdArgs.containsKey(cmd)))
.forEach(cmd -> cmdArgs.get(cmd).forEach(cmdArg -> {
assertEquals(EXIT_CODE_OK, execute(cmd.text(), cmdArg));
assertContains(log, testOut.toString(), warning);
}));
}
@Override
public void initialize(final URL location, final ResourceBundle resources) {
super.initialize(location, resources);
mainPane.managedProperty().bind(mainPane.visibleProperty());
fillPane.managedProperty().bind(fillPane.visibleProperty());
hatchingsPane.managedProperty().bind(hatchingsPane.visibleProperty());
gradientPane.managedProperty().bind(gradientPane.visibleProperty());
final Map<FillingStyle, Image> cache = new EnumMap<>(FillingStyle.class);
cache.put(FillingStyle.NONE, new Image("/res/hatch/hatch.none.png")); //NON-NLS
cache.put(FillingStyle.PLAIN, new Image("/res/hatch/hatch.solid.png")); //NON-NLS
cache.put(FillingStyle.CLINES, new Image("/res/hatch/hatch.cross.png")); //NON-NLS
cache.put(FillingStyle.CLINES_PLAIN, new Image("/res/hatch/hatchf.cross.png")); //NON-NLS
cache.put(FillingStyle.HLINES, new Image("/res/hatch/hatch.horiz.png")); //NON-NLS
cache.put(FillingStyle.HLINES_PLAIN, new Image("/res/hatch/hatchf.horiz.png")); //NON-NLS
cache.put(FillingStyle.VLINES, new Image("/res/hatch/hatch.vert.png")); //NON-NLS
cache.put(FillingStyle.VLINES_PLAIN, new Image("/res/hatch/hatchf.vert.png")); //NON-NLS
cache.put(FillingStyle.GRAD, new Image("/res/hatch/gradient.png")); //NON-NLS
initComboBox(fillStyleCB, cache, FillingStyle.values());
}
/**
* Initialize the log.
*
* @param properties properties with pegasus prefix stripped.
* @param level
* @param jsonFileMap
* @throws IOException
*/
public void initialze(
Properties properties, Level level, EnumMap<BATCH_ENTITY_TYPE, String> jsonFileMap)
throws IOException {
// "405596411149";
mLogger = Logger.getLogger(Synch.class.getName());
mLogger.setLevel(level);
mAWSAccountID = getProperty(properties, Synch.AWS_PROPERTY_PREFIX, "account");
mAWSRegion =
Region.of(
getProperty(
properties, Synch.AWS_PROPERTY_PREFIX, "region")); // "us-west-2"
mPrefix = getProperty(properties, Synch.AWS_BATCH_PROPERTY_PREFIX, "prefix");
mDeleteOnExit = new EnumMap<>(BATCH_ENTITY_TYPE.class);
mCommonFilesToS3 = new LinkedList<String>();
mS3BucketKeyPrefix = "";
mJobstateWriter = new AWSJobstateWriter();
mJobstateWriter.initialze(new File("."), mPrefix, mLogger);
mJobMap = new HashMap();
mExecutorService = Executors.newFixedThreadPool(2);
mBatchClient = BatchClient.builder().region(mAWSRegion).build();
mDoneWithJobSubmits = false;
mExitCode = 0;
}
private EnumMap<Planet, Double> calcOchchaBala() {
double[] debiliPos = {190.0, 213.0, 118.0, 345.0, 275.0, 177.0, 20.0};
EnumMap<Planet, Double> OchchaBala = new EnumMap<Planet, Double>(
Planet.class);
for (Planet p : Planet.majorPlanets()) {
double balaVal = Math.abs(planetPosition.get(p)
- debiliPos[p.ordinal()]) / 3;
if (balaVal > 60.00) {
balaVal = 120.00 - balaVal;
}
OchchaBala.put(p, balaVal);
}
return OchchaBala;
}
/**
*
*/
public void prepareMatrixJfMapAquisitionsAquisitions() {
// build session-wide marixJf for each type of fit function
matrixJfMapAquisitionsAquisitions = new EnumMap<>(FitFunctionTypeEnum.class);
// be sure times are prepared for standards AND all the work needed to support smoothing splines
//if ( Jgammag == null ) {
// we are now recalculating Jf each time to accomodate changes in included standards ... could be streamlined to only happen on count
prepareSessionWithAquisitionTimes();
int countOfAquisitions = activeXvalues.length;
// prepare spline Jf
Matrix Jfg = new Matrix(countOfAquisitions, countOfAquisitions);
Matrix Jfgamma = new Matrix(countOfAquisitions, countOfAquisitions);
for (int k = 0; k < activeXvalues.length; k++) {
populateJacobianGAndGamma(k, activeXvalues[k], Jfg, Jfgamma);
}
Matrix Jf = Jfg.plus(Jfgamma.times(Jgammag));
matrixJfMapAquisitionsAquisitions.put(FitFunctionTypeEnum.SMOOTHING_SPLINE, Jf);
// prepare LM exponential Jf
Jf = new Matrix(countOfAquisitions, 3);
// the LM fit function will have to populate Jf on demand as it depends on the fit parameters
matrixJfMapAquisitionsAquisitions.put(FitFunctionTypeEnum.EXPONENTIAL, Jf);
// prepare line Jf
Jf = new Matrix(countOfAquisitions, 2, 1.0);
for (int i = 0; i < countOfAquisitions; i++) {
Jf.set(i, 1, activeXvalues[i]);
}
matrixJfMapAquisitionsAquisitions.put(FitFunctionTypeEnum.LINE, Jf);
// mean has no Jf
matrixJfMapAquisitionsAquisitions.put(FitFunctionTypeEnum.MEAN, null);
}
private static EnumMap<Wrapper, MethodHandle>[] newWrapperCaches(int n) {
@SuppressWarnings("unchecked") // generic array creation
EnumMap<Wrapper, MethodHandle>[] caches
= (EnumMap<Wrapper, MethodHandle>[]) new EnumMap<?,?>[n];
for (int i = 0; i < n; i++)
caches[i] = new EnumMap<>(Wrapper.class);
return caches;
}
/**
* Cache the built-in ECMAScript objects to protect them against
* modifications by the script. This method is called automatically by
* {@link ScriptRuntime#initStandardObjects ScriptRuntime.initStandardObjects}
* if the scope argument is an instance of this class. It only has to be
* called by the embedding if a top-level scope is not initialized through
* <code>initStandardObjects()</code>.
*/
public void cacheBuiltins() {
ctors = new EnumMap<Builtins, BaseFunction>(Builtins.class);
for (Builtins builtin : Builtins.values()) {
Object value = ScriptableObject.getProperty(this, builtin.name());
if (value instanceof BaseFunction) {
ctors.put(builtin, (BaseFunction)value);
}
}
}
private void initDefaultInterReferenceMaterialReproducibilityMap() {
// set up default defaultInterReferenceMaterialReproducibility
ValueModel r206_238irmr = new ValueModel("r206_238irmr", new BigDecimal(0.01), "NONE", BigDecimal.ZERO, BigDecimal.ZERO);
ValueModel r206_207irmr = new ValueModel("r206_207irmr", new BigDecimal(0.01), "NONE", BigDecimal.ZERO, BigDecimal.ZERO);
ValueModel r208_232irmr = new ValueModel("r208_232irmr", new BigDecimal(0.01), "NONE", BigDecimal.ZERO, BigDecimal.ZERO);
defaultInterReferenceMaterialReproducibilityMap = new EnumMap<>(RadRatios.class);
defaultInterReferenceMaterialReproducibilityMap.put(RadRatios.r206_238r, r206_238irmr);
defaultInterReferenceMaterialReproducibilityMap.put(RadRatios.r206_207r, r206_207irmr);
defaultInterReferenceMaterialReproducibilityMap.put(RadRatios.r208_232r, r208_232irmr);
}
protected List<?> getRepositoryObjects( RepositoryObjectType repositoryObjectType, boolean cached ) throws KettleException {
if ( cached ) {
return loadAndCacheSharedObjects( true ).get( repositoryObjectType );
} else {
Map<RepositoryObjectType, List<? extends SharedObjectInterface>> sharedObjects = new EnumMap<>(
RepositoryObjectType.class );
readSharedObjects( sharedObjects, repositoryObjectType );
return deepCopy( sharedObjects ).get( repositoryObjectType );
}
}
public DigitalObjectEditor(ClientMessages i18n, PlaceController places, boolean embedded) {
this.i18n = i18n;
this.places = places;
this.editorCache = new EnumMap<DatastreamEditorType, EditorDescriptor>(DatastreamEditorType.class);
this.widget = new VLayout();
this.lblHeader = new Label();
lblHeader.setAutoHeight();
lblHeader.setPadding(4);
lblHeader.setStyleName(Editor.CSS_PANEL_DESCRIPTION_TITLE);
this.actionSource = new ActionSource(this);
this.embeddedView = embedded;
this.toolbar = Actions.createToolStrip();
this.editorContainer = new VLayout();
editorContainer.setLayoutMargin(4);
editorContainer.setWidth100();
editorContainer.setHeight100();
widget.addMember(lblHeader);
widget.addMember(toolbar);
if (embedded) {
widget.addMember(editorContainer);
} else {
editorContainer.setResizeBarTarget("next");
HLayout multiView = new HLayout();
multiView.setWidth100();
multiView.setHeight100();
multiView.setLayoutMargin(4);
multiView.addMember(editorContainer);
initOptionalEditor(multiView);
widget.addMember(multiView);
}
}
public EnumMap<Category, ArrayList<UnitDefinition>> getAllUnitDefinitions() {
final EnumMap<Category, ArrayList<UnitDefinition>> UNIT_TYPES = new EnumMap<>(Category.class);
final ArrayList<Category> CATEGORY_LIST = new ArrayList<>(Category.values().length);
CATEGORY_LIST.addAll(Arrays.asList(Category.values()));
CATEGORY_LIST.forEach(category -> UNIT_TYPES.put(category, new ArrayList<>()));
for (UnitDefinition unitDefinition : UnitDefinition.values()) {
UNIT_TYPES.get(unitDefinition.UNIT.getCategory()).add(unitDefinition);
}
return UNIT_TYPES;
}
@SuppressWarnings("serial")
@Test
public void multiFrameTranslation() throws CompoundNotFoundException {
TranscriptionEngine e = TranscriptionEngine.getDefault();
DNASequence dna = new DNASequence("ATGGCGTGA");
Map<Frame, String> expectedTranslations = new EnumMap<Frame, String>(Frame.class) {
{
put(Frame.ONE, "MA");
put(Frame.TWO, "WR");
put(Frame.THREE, "GV");
put(Frame.REVERSED_ONE, "SRH");
put(Frame.REVERSED_TWO, "HA");
put(Frame.REVERSED_THREE, "TP");
}
};
Map<Frame, Sequence<AminoAcidCompound>> translations =
e.multipleFrameTranslation(dna, Frame.getAllFrames());
for (Entry<Frame, Sequence<AminoAcidCompound>> entry : translations.entrySet()) {
String expected = expectedTranslations.get(entry.getKey());
Sequence<AminoAcidCompound> protein = entry.getValue();
assertThat("Checking 6 frame translation", protein.toString(), is(expected));
}
}
@Override
protected void save() {
Map<FieldKey, String> fieldKeyValueMap = new EnumMap<>(FieldKey.class);
fieldKeyValueMap.put(FieldKey.TITLE, songTitle.getText().toString());
fieldKeyValueMap.put(FieldKey.ALBUM, albumTitle.getText().toString());
fieldKeyValueMap.put(FieldKey.ARTIST, artist.getText().toString());
fieldKeyValueMap.put(FieldKey.GENRE, genre.getText().toString());
fieldKeyValueMap.put(FieldKey.YEAR, year.getText().toString());
fieldKeyValueMap.put(FieldKey.TRACK, trackNumber.getText().toString());
fieldKeyValueMap.put(FieldKey.LYRICS, lyrics.getText().toString());
writeValuesToFiles(fieldKeyValueMap, null);
}