java.util.EnumMap Java Examples

The following examples show how to use java.util.EnumMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: j2objc   Author: google   File: RelativeDateTimeFormatter.java    License: Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #2
Source Project: prayer-times-android   Author: metinkale38   File: Cities.java    License: Apache License 2.0 6 votes vote down vote up
@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());

}
 
Example #3
Source Project: netbeans   Author: apache   File: UserAnnotationPanel.java    License: Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #4
Source Project: fastods   Author: jferard   File: DataStyles.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * @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);
}
 
Example #5
Source Project: prayer-times-android   Author: metinkale38   File: Cities.java    License: Apache License 2.0 6 votes vote down vote up
@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());

}
 
Example #6
Source Project: gama   Author: gama-platform   File: FileSourceGEXF.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * <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");
}
 
Example #7
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: DistinctEntrySetElements.java    License: GNU General Public License v2.0 6 votes vote down vote up
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.");
    }
}
 
Example #8
Source Project: tutorials   Author: eugenp   File: PizzaUnitTest.java    License: MIT License 6 votes vote down vote up
@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);
}
 
Example #9
Source Project: scelight   Author: icza   File: ExpansionComp.java    License: Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example #10
Source Project: mapleLemon   Author: icelemon1314   File: WrodlPartyService.java    License: GNU General Public License v2.0 6 votes vote down vote up
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());
    }
}
 
Example #11
Source Project: aion   Author: aionnetwork   File: ChainConfiguration.java    License: MIT License 6 votes vote down vote up
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);
}
 
Example #12
Source Project: jdk8u60   Author: chenghanpeng   File: Locations.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #13
Source Project: batfish   Author: batfish   File: BgpProcess.java    License: Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #14
Source Project: TencentKona-8   Author: Tencent   File: Locations.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #15
Source Project: thunderstorm   Author: zitmen   File: MoleculeDescriptor.java    License: GNU General Public License v3.0 6 votes vote down vote up
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)];
}
 
Example #16
Source Project: javacore   Author: dunwu   File: App.java    License: Creative Commons Attribution Share Alike 4.0 International 6 votes vote down vote up
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());
    }
}
 
Example #17
Source Project: Astrosoft   Author: erajasekar   File: ShadBala.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
	}
 
Example #18
Source Project: ignite   Author: apache   File: GridCommandHandlerClusterByClassTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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);
        }));
}
 
Example #19
Source Project: latexdraw   Author: latexdraw   File: ShapeFillingCustomiser.java    License: GNU General Public License v3.0 6 votes vote down vote up
@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());
}
 
Example #20
Source Project: pegasus   Author: pegasus-isi   File: Synch.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #21
Source Project: Astrosoft   Author: erajasekar   File: ShadBala.java    License: GNU General Public License v2.0 6 votes vote down vote up
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;
	}
 
Example #22
Source Project: ET_Redux   Author: CIRDLES   File: DownholeFractionationDataModel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 */
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);
}
 
Example #23
Source Project: openjdk-8-source   Author: keerath   File: ValueConversions.java    License: GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #24
Source Project: openbd-core   Author: OpenBD   File: TopLevel.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example #25
Source Project: ET_Redux   Author: CIRDLES   File: ReduxLabData.java    License: Apache License 2.0 5 votes vote down vote up
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);
    }
 
Example #26
Source Project: pentaho-kettle   Author: pentaho   File: PurRepository.java    License: Apache License 2.0 5 votes vote down vote up
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 );
  }
}
 
Example #27
Source Project: proarc   Author: proarc   File: DigitalObjectEditor.java    License: GNU General Public License v3.0 5 votes vote down vote up
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);
    }
}
 
Example #28
Source Project: charts   Author: HanSolo   File: Converter.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #29
Source Project: biojava   Author: biojava   File: TranslationTest.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@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));
	}
}
 
Example #30
Source Project: Orin   Author: aliumujib   File: SongTagEditorActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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);
}