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 Boolean.

public class EdmBoolean extends AbstractSimpleType {
  private static final EdmBoolean instance = new EdmBoolean();
  public static EdmBoolean getInstance() {
    return ;
  public boolean isCompatible(final EdmSimpleType simpleType) {
    return simpleType instanceof Bit || simpleType instanceof EdmBoolean;
  public Class<?> getDefaultType() {
    return Boolean.class;
  public boolean validate(final String valuefinal EdmLiteralKind literalKindfinal EdmFacets facets) {
    return value == null ?
        facets == null || facets.isNullable() == null || facets.isNullable() :
  private static boolean validateLiteral(final String value) {
    return "true".equals(value) || "1".equals(value)
        || "false".equals(value) || "0".equals(value);
  protected <T> T internalValueOfString(final String valuefinal EdmLiteralKind literalKindfinal EdmFacets facetsfinal Class<T> returnTypethrows EdmSimpleTypeException {
    if (validateLiteral(value)) {
      if (returnType.isAssignableFrom(Boolean.class)) {
        return returnType.cast(Boolean.valueOf("true".equals(value) || "1".equals(value)));
      } else {
    } else {
  protected <T> String internalValueToString(final T valuefinal EdmLiteralKind literalKindfinal EdmFacets facetsthrows EdmSimpleTypeException {
    if (value instanceof Boolean) {
      return Boolean.toString((Booleanvalue);
    } else {
New to GrepCode? Check out our FAQ X