Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2013 SAP AG Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
Implementation of the EDM simple type Guid.

public class EdmGuid extends AbstractSimpleType {
  private static final String PATTERN = "\\p{XDigit}{8}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{12}";
  private static final EdmGuid instance = new EdmGuid();
  public static EdmGuid getInstance() {
    return ;
  public Class<?> getDefaultType() {
    return UUID.class;
  public boolean validate(final String valuefinal EdmLiteralKind literalKindfinal EdmFacets facets) {
    return value == null ?
        facets == null || facets.isNullable() == null || facets.isNullable() :
  private boolean validateLiteral(final String valuefinal EdmLiteralKind literalKind) {
    return value.matches(literalKind == . ? toUriLiteral() : );
  protected <T> T internalValueOfString(final String valuefinal EdmLiteralKind literalKindfinal EdmFacets facetsfinal Class<T> returnTypethrows EdmSimpleTypeException {
    UUID result;
    if (validateLiteral(valueliteralKind)) {
      result = UUID.fromString(
          literalKind == . ? value.substring(5, value.length() - 1) : value);
    } else {
    if (returnType.isAssignableFrom(UUID.class)) {
      return returnType.cast(result);
    } else {
  protected <T> String internalValueToString(final T valuefinal EdmLiteralKind literalKindfinal EdmFacets facetsthrows EdmSimpleTypeException {
    if (value instanceof UUID) {
      return ((UUIDvalue).toString();
    } else {
  public String toUriLiteral(final String literal) {
    return "guid'" + literal + "'";
New to GrepCode? Check out our FAQ X