コード例 #1
0
 @SuppressWarnings("unchecked")
 private void setConfigParameter(List<Boolean> flags, Builder builder, Fragment fragment) {
   int index = fragment.ordinal();
   if (flags.get(index)) {
     Builder b = null;
     switch (fragment) {
       case CAPACITY:
         b =
             builder.setCapacity( //
                 (Range<Float>) RANGES[2 * index], //
                 (Range<Float>) RANGES[2 * index + 1]);
         break;
       case CAPACITY_ATTACK:
         b =
             builder.setCapacityAttack( //
                 (Range<Float>) RANGES[2 * index], //
                 (Range<Float>) RANGES[2 * index + 1]);
         break;
       case CAPACITY_DECAY:
         b =
             builder.setCapacityDecay( //
                 (Range<Float>) RANGES[2 * index], //
                 (Range<Float>) RANGES[2 * index + 1]);
         break;
       case STRENGTH:
         b =
             builder.setStrength( //
                 (Range<Float>) RANGES[2 * index], //
                 (Range<Float>) RANGES[2 * index + 1]);
         break;
       case STRENGTH_ATTACK:
         b =
             builder.setStrengthAttack( //
                 (Range<Float>) RANGES[2 * index], //
                 (Range<Float>) RANGES[2 * index + 1]);
         break;
       case STRENGTH_DECAY:
         b =
             builder.setStrengthDecay( //
                 (Range<Float>) RANGES[2 * index], //
                 (Range<Float>) RANGES[2 * index + 1]);
         break;
       case IS_INHIBITORY:
         b =
             builder.setInhibitoryFlag( //
                 (Range<Boolean>) RANGES[2 * index], //
                 (Range<Boolean>) RANGES[2 * index + 1]);
         break;
       default:
         // nothing to set, just assign for post set test
         b = builder;
         break;
     }
     assertThat(
         "", //
         b,
         isSameAs(builder));
   }
 }
コード例 #2
0
 private void testConfigsParameter(
     List<Boolean> flags,
     LinkConfiguration linkConfig,
     Fragment fragment,
     LinkConfiguration template) {
   if (!Fragment.OUTPUT_ENERGY.equals(fragment)) {
     int index = fragment.ordinal();
     if (flags.get(index)) {
       assertThat(
           fragment.getParameterId().toString(), //
           ((RangeXParameter<?>) linkConfig.getParameter(fragment.getParameterId()))
               .getLifetimeRange(), //
           isEqualTo(RANGES[2 * index]));
       assertThat(
           fragment.getParameterId().toString(), //
           ((RangeXParameter<?>) linkConfig.getParameter(fragment.getParameterId()))
               .getInitialRange(), //
           isEqualTo(RANGES[2 * index + 1]));
     } else {
       assertThat(
           fragment.getParameterId().toString(), //
           ((RangeXParameter<?>) linkConfig.getParameter(fragment.getParameterId()))
               .getLifetimeRange(), //
           isEqualTo(
               ((RangeXParameter<?>) template.getParameter(fragment.getParameterId()))
                   .getLifetimeRange()));
       assertThat(
           fragment.getParameterId().toString(), //
           ((RangeXParameter<?>) linkConfig.getParameter(fragment.getParameterId()))
               .getInitialRange(), //
           isEqualTo(
               ((RangeXParameter<?>) template.getParameter(fragment.getParameterId()))
                   .getInitialRange()));
     }
   }
 }