Translate a {@link HalFormsConfiguration} into a {@link HalConfiguration}.

@return
485346
public HalConfiguration toHalConfiguration() {

		if (this.getRenderSingleLinks() == RenderSingleLinks.AS_SINGLE) {
			return new HalConfiguration().withRenderSingleLinks(HalConfiguration.RenderSingleLinks.AS_SINGLE);
		}

		if (this.getRenderSingleLinks() == RenderSingleLinks.AS_ARRAY) {
			return new HalConfiguration().withRenderSingleLinks(HalConfiguration.RenderSingleLinks.AS_ARRAY);
		}

		throw new IllegalStateException("Don't know how to translate " + this);
	}
481791
@SuppressWarnings({"rawtypes", "unchecked"})
  public static Config translateComponentConfig(Map stormConfig) {
    Config heronConfig;
    if (stormConfig != null) {
      heronConfig = new Config((Map<String, Object>) stormConfig);
    } else {
      heronConfig = new Config();
    }

    doStormTranslation(heronConfig);

    return heronConfig;
  }
287393
public HalFormsTemplate andContentType(MediaType mediaType) {

		Assert.notNull(mediaType, "Media type must not be null!");

		List<MediaType> contentTypes = new ArrayList<>(this.contentTypes);
		contentTypes.add(mediaType);

		return new HalFormsTemplate(title, httpMethod, properties, contentTypes);
	}
924905
public synchronized Configuration loadConfiguration() {
    if (configurationBuffer.position(0).readByte() == 1) {
      return new Configuration(
          configurationBuffer.readLong(),
          configurationBuffer.readLong(),
          configurationBuffer.readLong(),
          serializer.readObject(configurationBuffer)
      );
    }
    return null;
  }
140429
private List<HalFormsProperty> determineInputs() {

		if (!ENTITY_ALTERING_METHODS.contains(getHttpMethod())) {
			return Collections.emptyList();
		}

		return PropertyUtils.findPropertyNames(getInputType()).stream() //
				.map(propertyName -> new HalFormsProperty() //
						.withName(propertyName) //
						.withRequired(REQUIRED_METHODS.contains(getHttpMethod()))) //
				.collect(Collectors.toList());
	}
1345501
private static Spliterator.OfDouble adapt(Spliterator<Double> s) {
        if (s instanceof Spliterator.OfDouble) {
            return (Spliterator.OfDouble) s;
        } else {
//            if (Tripwire.ENABLED)
//                Tripwire.trip(AbstractPipeline.class,
//                              "using DoubleStream.adapt(Spliterator<Double> s)");
            throw new UnsupportedOperationException("DoubleStream.adapt(Spliterator<Double> s)");
        }
    }
482267
public Vector3d half(Vector3dc other, Vector3d dest) {
        return half(other.x(), other.y(), other.z(), dest);
    }
506368
private static ServerTransportConfig convertConfig(ServerConfig serverConfig) {
        ServerTransportConfig serverTransportConfig = new ServerTransportConfig();
        serverTransportConfig.setPort(serverConfig.getPort());
        serverTransportConfig.setProtocolType(serverConfig.getProtocol());
        serverTransportConfig.setHost(serverConfig.getBoundHost());
        serverTransportConfig.setContextPath(serverConfig.getContextPath());
        serverTransportConfig.setBizMaxThreads(serverConfig.getMaxThreads());
        serverTransportConfig.setBizPoolType(serverConfig.getThreadPoolType());
        serverTransportConfig.setIoThreads(serverConfig.getIoThreads());
        serverTransportConfig.setChannelListeners(serverConfig.getOnConnect());
        serverTransportConfig.setMaxConnection(serverConfig.getAccepts());
        serverTransportConfig.setPayload(serverConfig.getPayload());
        serverTransportConfig.setTelnet(serverConfig.isTelnet());
        serverTransportConfig.setUseEpoll(serverConfig.isEpoll());
        serverTransportConfig.setBizPoolQueueType(serverConfig.getQueueType());
        serverTransportConfig.setBizPoolQueues(serverConfig.getQueues());
        serverTransportConfig.setDaemon(serverConfig.isDaemon());
        serverTransportConfig.setParameters(serverConfig.getParameters());
        serverTransportConfig.setContainer(serverConfig.getTransport());
        return serverTransportConfig;
    }
712955
protected Transformer _newTransformer()
    {
        Transformer  transformer = null;

        if (_stylesheet == null) {
            try {
                transformer = TransformerFactory.newInstance().newTransformer();
            } catch (Exception ex) {
                throw new XmlException( ex );
            }

            return transformer;
        }

        if (_templates == null) {
            _templates = _getTemplates( _stylesheet );
        }

        try {
            transformer = _templates.newTransformer();
                                     //throws TransformerConfigurationException

            if (_params.size() > 0) {
                for (String  name : _params.keySet()) {
                    Object  value = _params.get( name );
                    transformer.setParameter( name, value );
                }
            }
        } catch (Exception ex) {
            throw new XmlException( ex );
        }

        return transformer;
    }
1161548
public PositionAlignmentOptions setHorizontalAlignment(PositionRelation horizontalAlignment, int offsetLeft)
	{
		switch (horizontalAlignment)
		{
			case LEFT:
			case CENTER:
			case RIGHT:
				break;
			default:
				throw new IllegalArgumentException("Illegal value for the horizontal alignment property");
		}

		this.horizontalAlignment = horizontalAlignment;
		this.offsetLeft = offsetLeft;
		return this;
	}
1227779
private Configuration makeEvaluatorConfiguration(final Configuration contextConfiguration,
                                                   final Optional<Configuration> serviceConfiguration,
                                                   final Optional<Configuration> taskConfiguration) {

    final String contextConfigurationString = this.configurationSerializer.toString(contextConfiguration);

    final Optional<String> taskConfigurationString;
    if (taskConfiguration.isPresent()) {
      taskConfigurationString = Optional.of(this.configurationSerializer.toString(taskConfiguration.get()));
    } else {
      taskConfigurationString = Optional.empty();
    }

    final Optional<Configuration> mergedServiceConfiguration = makeRootServiceConfiguration(serviceConfiguration);
    if (mergedServiceConfiguration.isPresent()) {
      final String serviceConfigurationString = this.configurationSerializer.toString(mergedServiceConfiguration.get());
      return makeEvaluatorConfiguration(contextConfigurationString, Optional.<String>empty(),
          Optional.of(serviceConfigurationString), taskConfigurationString);
    } else {
      return makeEvaluatorConfiguration(
          contextConfigurationString, Optional.<String>empty(), Optional.<String>empty(), taskConfigurationString);
    }
  }
498101
public static <T> HalFormsDocument<T> forResource(@Nullable T resource) {
		return new HalFormsDocument<T>().withResource(resource);
	}
513941
private Configuration getMimeTypeConfiguration() {
		return new AbstractConfiguration() {

			@Override
			public void configure(WebAppContext context) throws Exception {
				MimeTypes mimeTypes = context.getMimeTypes();
				for (MimeMappings.Mapping mapping : getMimeMappings()) {
					mimeTypes.addMimeMapping(mapping.getExtension(),
							mapping.getMimeType());
				}
			}

		};
	}
674235
public long halfDigest() {
    long value = 0;
    for (int i = 0; i < 8; i++)
      value |= ((digest[i] & 0xffL) << (8*(7-i)));
    return value;
  }

  /**
   * Return a 32-bit digest of the MD5.
   * @return the first 4 bytes of the md5
   */
  public int quarterDigest() {
    int value = 0;
    for (int i = 0; i < 4; i++)
      value |= ((digest[i] & 0xff) << (8*(3-i)));
    return value;    
  }

  /** Returns true iff <code>o</code> is an MD5Hash whose digest contains the
   * same values.  */
  public boolean equals(Object o) {
    if (!(o instanceof MD5Hash))
      return false;
    MD5Hash other = (MD5Hash)o;
    return Arrays.equals(this.digest, other.digest);
  }

  /** Returns a hash code value for this object.
   * Only uses the first 4 bytes, since md5s are evenly distributed.
   */
  public int hashCode() {
    return quarterDigest();
  }


  /** Compares this object with the specified object for order.*/
  public int compareTo(MD5Hash that) {
    return WritableComparator.compareBytes(this.digest, 0, MD5_LEN,
                                           that.digest, 0, MD5_LEN);
  }

  /** A WritableComparator optimized for MD5Hash keys. */
  public static class Comparator extends WritableComparator {
    public Comparator() {
      super(MD5Hash.class);
    }

    public int compare(byte[] b1, int s1, int l1,
                       byte[] b2, int s2, int l2) {
      return compareBytes(b1, s1, MD5_LEN, b2, s2, MD5_LEN);
    }
  }

  static {                                        // register this comparator
    WritableComparator.define(MD5Hash.class, new Comparator());
  }

  private static final char[] HEX_DIGITS =
  {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};

  /** Returns a string representation of this object. */
  public String toString() {
    StringBuffer buf = new StringBuffer(MD5_LEN*2);
    for (int i = 0; i < MD5_LEN; i++) {
      int b = digest[i];
      buf.append(HEX_DIGITS[(b >> 4) & 0xf]);
      buf.append(HEX_DIGITS[b & 0xf]);
    }
    return buf.toString();
  }

  /** Sets the digest value from a hex string. */
  public void setDigest(String hex) {
    if (hex.length() != MD5_LEN*2)
      throw new IllegalArgumentException("Wrong length: " + hex.length());
    byte[] digest = new byte[MD5_LEN];
    for (int i = 0; i < MD5_LEN; i++) {
      int j = i << 1;
      digest[i] = (byte)(charToNibble(hex.charAt(j)) << 4 |
                         charToNibble(hex.charAt(j+1)));
    }
    this.digest = digest;
  }

  private static final int charToNibble(char c) {
    if (c >= '0' && c <= '9') {
      return c - '0';
    } else if (c >= 'a' && c <= 'f') {
      return 0xa + (c - 'a');
    } else if (c >= 'A' && c <= 'F') {
      return 0xA + (c - 'A');
    } else {
      throw new RuntimeException("Not a hex character: " + c);
    }
  }


}
853273
public Vector3f half(float x, float y, float z) {
        return half(x, y, z, thisOrNew());
    }
1030127
public static Builder from(XmlMultiConfiguration config) {
    return new Builder() {
      @Override
      public Builder withManager(String identity, Configuration configuration) {
        Map<String, Config> configurations = new HashMap<>(config.configurations);
        configurations.put(identity, new SingleConfig(configuration));
        return from(new XmlMultiConfiguration(configurations));
      }

      @Override
      public Builder withoutManager(String identity) {
        Map<String, Config> configurations = config.configurations;
        configurations.remove(identity);
        return from(new XmlMultiConfiguration(configurations));
      }

      @Override
      public Variant withManager(String identity) {
        Map<String, Configuration> variants = new HashMap<>();

        Config current = config.configurations.get(identity);
        if (current instanceof VariantConfig) {
          variants.putAll(((VariantConfig) current).configs);
        } else if (current != null) {
          throw new IllegalStateException("Existing non-variant configuration cannot be replaced - it must be removed first.");
        }

        return new Variant() {
          @Override
          public Variant withoutVariant(String variant) {
            variants.remove(variant);
            return this;
          }

          @Override
          public Variant variant(String variant, Configuration configuration) {
            variants.put(variant, configuration);
            return this;
          }

          @Override
          public Builder withoutManager(String identity) {
            return from(build()).withoutManager(identity);
          }

          @Override
          public Builder withManager(String identity, Configuration configuration) {
            return from(build()).withManager(identity, configuration);
          }

          @Override
          public Variant withManager(String identity) {
            return from(build()).withManager(identity);
          }

          @Override
          public XmlMultiConfiguration build() {
            Map<String, Config> configurations = new HashMap<>(config.configurations);
            configurations.put(identity, new VariantConfig(variants));
            return new XmlMultiConfiguration(configurations);
          }
        };
      }

      @Override
      public XmlMultiConfiguration build() {
        return config;
      }
    };
  }
147098
private static Stage configureParser() {
        Stage startStage = new StartStage();
        Stage negativeInfinityStage = new NegativeInfinityStage();
        Stage positiveInfinityStage = new PositiveInfinityStage();
        NegateStage negateStage = new NegateStage();
        BracketStage.OpenBracketStage openBraceStage = new BracketStage.OpenBracketStage();
        NumberBoundaryStage.LeftBoundaryStage startBoundaryStage = new NumberBoundaryStage.LeftBoundaryStage();
        NumberBoundaryStage.RightBoundaryStage rightBoundaryStage = new NumberBoundaryStage.RightBoundaryStage();
        SeparatorStage separatorStage = new SeparatorStage();
        BracketStage.ClosedBracketStage closedBraketStage = new BracketStage.ClosedBracketStage();

        startStage.addTransition(negateStage);
        startStage.addTransition(openBraceStage);
        startStage.addTransition(negativeInfinityStage);
        startStage.addTransition(startBoundaryStage);

        negateStage.addTransition(negativeInfinityStage);
        negateStage.addTransition(openBraceStage);
        negateStage.addTransition(startBoundaryStage);

        openBraceStage.addTransition(startBoundaryStage);
        startBoundaryStage.addTransition(separatorStage);
        negativeInfinityStage.addTransition(separatorStage);

        separatorStage.addTransition(positiveInfinityStage);
        separatorStage.addTransition(rightBoundaryStage);

        rightBoundaryStage.addTransition(closedBraketStage);

        return startStage;
    }