Java Code Examples for org.apache.hadoop.util.StringUtils#equalsIgnoreCase()

The following examples show how to use org.apache.hadoop.util.StringUtils#equalsIgnoreCase() . 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 File: AtlasStructDef.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
public void addAttribute(AtlasAttributeDef attributeDef) {
    if (attributeDef == null) {
        return;
    }

    List<AtlasAttributeDef> a = this.attributeDefs;

    List<AtlasAttributeDef> tmpList = new ArrayList<>();
    if (CollectionUtils.isNotEmpty(a)) {
        // copy existing attributes, except ones having same name as the attribute being added
        for (AtlasAttributeDef existingAttrDef : a) {
            if (!StringUtils.equalsIgnoreCase(existingAttrDef.getName(), attributeDef.getName())) {
                tmpList.add(existingAttrDef);
            }
        }
    }
    tmpList.add(new AtlasAttributeDef(attributeDef));

    this.attributeDefs = tmpList;
}
 
Example 2
Source File: AtlasEnumDef.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
public void addElement(AtlasEnumElementDef elementDef) {
    List<AtlasEnumElementDef> e = this.elementDefs;

    List<AtlasEnumElementDef> tmpList = new ArrayList<>();
    if (CollectionUtils.isNotEmpty(e)) {
        // copy existing elements, except ones having same value as the element being added
        for (AtlasEnumElementDef existingElem : e) {
            if (!StringUtils.equalsIgnoreCase(existingElem.getValue(), elementDef.getValue())) {
                tmpList.add(existingElem);
            }
        }
    }
    tmpList.add(new AtlasEnumElementDef(elementDef));

    this.elementDefs = tmpList;
}
 
Example 3
Source File: AtlasStructDef.java    From atlas with Apache License 2.0 6 votes vote down vote up
public void addAttribute(AtlasAttributeDef attributeDef) {
    if (attributeDef == null) {
        return;
    }

    List<AtlasAttributeDef> a = this.attributeDefs;

    List<AtlasAttributeDef> tmpList = new ArrayList<>();
    if (CollectionUtils.isNotEmpty(a)) {
        // copy existing attributes, except ones having same name as the attribute being added
        for (AtlasAttributeDef existingAttrDef : a) {
            if (!StringUtils.equalsIgnoreCase(existingAttrDef.getName(), attributeDef.getName())) {
                tmpList.add(existingAttrDef);
            }
        }
    }
    tmpList.add(new AtlasAttributeDef(attributeDef));

    this.attributeDefs = tmpList;
}
 
Example 4
Source File: AtlasStructDef.java    From atlas with Apache License 2.0 6 votes vote down vote up
public void removeAttribute(String attrName) {
    List<AtlasAttributeDef> a = this.attributeDefs;

    if (hasAttribute(a, attrName)) {
        List<AtlasAttributeDef> tmpList = new ArrayList<>();

        // copy existing attributes, except ones having same name as the attribute being removed
        for (AtlasAttributeDef existingAttrDef : a) {
            if (!StringUtils.equalsIgnoreCase(existingAttrDef.getName(), attrName)) {
                tmpList.add(existingAttrDef);
            }
        }

        this.attributeDefs = tmpList;
    }
}
 
Example 5
Source File: AtlasEnumDef.java    From atlas with Apache License 2.0 6 votes vote down vote up
public void addElement(AtlasEnumElementDef elementDef) {
    List<AtlasEnumElementDef> e = this.elementDefs;

    List<AtlasEnumElementDef> tmpList = new ArrayList<>();
    if (CollectionUtils.isNotEmpty(e)) {
        // copy existing elements, except ones having same value as the element being added
        for (AtlasEnumElementDef existingElem : e) {
            if (!StringUtils.equalsIgnoreCase(existingElem.getValue(), elementDef.getValue())) {
                tmpList.add(existingElem);
            }
        }
    }
    tmpList.add(new AtlasEnumElementDef(elementDef));

    this.elementDefs = tmpList;
}
 
Example 6
Source File: AtlasEnumDef.java    From atlas with Apache License 2.0 6 votes vote down vote up
public void removeElement(String elemValue) {
    List<AtlasEnumElementDef> e = this.elementDefs;

    // if element doesn't exist, no need to create the tmpList below
    if (hasElement(e, elemValue)) {
        List<AtlasEnumElementDef> tmpList = new ArrayList<>();

        // copy existing elements, except ones having same value as the element being removed
        for (AtlasEnumElementDef existingElem : e) {
            if (!StringUtils.equalsIgnoreCase(existingElem.getValue(), elemValue)) {
                tmpList.add(existingElem);
            }
        }

        this.elementDefs = tmpList;
    }
}
 
Example 7
Source File: AtlasEnumDef.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
public void removeElement(String elemValue) {
    List<AtlasEnumElementDef> e = this.elementDefs;

    // if element doesn't exist, no need to create the tmpList below
    if (hasElement(e, elemValue)) {
        List<AtlasEnumElementDef> tmpList = new ArrayList<>();

        // copy existing elements, except ones having same value as the element being removed
        for (AtlasEnumElementDef existingElem : e) {
            if (!StringUtils.equalsIgnoreCase(existingElem.getValue(), elemValue)) {
                tmpList.add(existingElem);
            }
        }

        this.elementDefs = tmpList;
    }
}
 
Example 8
Source File: AtlasEnumDef.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
private static AtlasEnumElementDef findElement(List<AtlasEnumElementDef> elementDefs, String elemValue) {
    AtlasEnumElementDef ret = null;

    if (CollectionUtils.isNotEmpty(elementDefs)) {
        for (AtlasEnumElementDef elementDef : elementDefs) {
            if (StringUtils.equalsIgnoreCase(elementDef.getValue(), elemValue)) {
                ret = elementDef;
                break;
            }
        }
    }

    return ret;
}
 
Example 9
Source File: Configuration.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Get the value of the <code>name</code> property as a <code>boolean</code>.
 * If no such property is specified, or if the specified value is not a valid
 * <code>boolean</code>, then <code>defaultValue</code> is returned.
 *
 * @param name property name.
 * @param defaultValue default value.
 * @return property value as a <code>boolean</code>,
 *         or <code>defaultValue</code>.
 */
public boolean getBoolean(String name, boolean defaultValue) {
  String valueString = getTrimmed(name);
  if (null == valueString || valueString.isEmpty()) {
    return defaultValue;
  }

  if (StringUtils.equalsIgnoreCase("true", valueString))
    return true;
  else if (StringUtils.equalsIgnoreCase("false", valueString))
    return false;
  else return defaultValue;
}
 
Example 10
Source File: Configuration.java    From big-c with Apache License 2.0 5 votes vote down vote up
/** 
 * Get the value of the <code>name</code> property as a <code>boolean</code>.  
 * If no such property is specified, or if the specified value is not a valid
 * <code>boolean</code>, then <code>defaultValue</code> is returned.
 * 
 * @param name property name.
 * @param defaultValue default value.
 * @return property value as a <code>boolean</code>, 
 *         or <code>defaultValue</code>. 
 */
public boolean getBoolean(String name, boolean defaultValue) {
  String valueString = getTrimmed(name);
  if (null == valueString || valueString.isEmpty()) {
    return defaultValue;
  }

  if (StringUtils.equalsIgnoreCase("true", valueString))
    return true;
  else if (StringUtils.equalsIgnoreCase("false", valueString))
    return false;
  else return defaultValue;
}
 
Example 11
Source File: XAttrHelper.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Build <code>XAttr</code> from name with prefix and value.
 * Name can not be null. Value can be null. The name and prefix 
 * are validated.
 * Both name and namespace are case sensitive.
 */
public static XAttr buildXAttr(String name, byte[] value) {
  Preconditions.checkNotNull(name, "XAttr name cannot be null.");
  
  final int prefixIndex = name.indexOf(".");
  if (prefixIndex < 3) {// Prefix length is at least 3.
    throw new HadoopIllegalArgumentException("An XAttr name must be " +
        "prefixed with user/trusted/security/system/raw, followed by a '.'");
  } else if (prefixIndex == name.length() - 1) {
    throw new HadoopIllegalArgumentException("XAttr name cannot be empty.");
  }
  
  NameSpace ns;
  final String prefix = name.substring(0, prefixIndex);
  if (StringUtils.equalsIgnoreCase(prefix, NameSpace.USER.toString())) {
    ns = NameSpace.USER;
  } else if (
      StringUtils.equalsIgnoreCase(prefix, NameSpace.TRUSTED.toString())) {
    ns = NameSpace.TRUSTED;
  } else if (
      StringUtils.equalsIgnoreCase(prefix, NameSpace.SYSTEM.toString())) {
    ns = NameSpace.SYSTEM;
  } else if (
      StringUtils.equalsIgnoreCase(prefix, NameSpace.SECURITY.toString())) {
    ns = NameSpace.SECURITY;
  } else if (
      StringUtils.equalsIgnoreCase(prefix, NameSpace.RAW.toString())) {
    ns = NameSpace.RAW;
  } else {
    throw new HadoopIllegalArgumentException("An XAttr name must be " +
        "prefixed with user/trusted/security/system/raw, followed by a '.'");
  }
  XAttr xAttr = (new XAttr.Builder()).setNameSpace(ns).setName(name.
      substring(prefixIndex + 1)).setValue(value).build();
  
  return xAttr;
}
 
Example 12
Source File: Configuration.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Get the value of the <code>name</code> property as a <code>boolean</code>.
 * If no such property is specified, or if the specified value is not a valid
 * <code>boolean</code>, then <code>defaultValue</code> is returned.
 *
 * @param name property name.
 * @param defaultValue default value.
 * @return property value as a <code>boolean</code>,
 *         or <code>defaultValue</code>.
 */
public boolean getBoolean(String name, boolean defaultValue) {
  String valueString = getTrimmed(name);
  if (null == valueString || valueString.isEmpty()) {
    return defaultValue;
  }

  if (StringUtils.equalsIgnoreCase("true", valueString))
    return true;
  else if (StringUtils.equalsIgnoreCase("false", valueString))
    return false;
  else return defaultValue;
}
 
Example 13
Source File: AtlasEnumDef.java    From atlas with Apache License 2.0 5 votes vote down vote up
private static AtlasEnumElementDef findElement(List<AtlasEnumElementDef> elementDefs, String elemValue) {
    AtlasEnumElementDef ret = null;

    if (CollectionUtils.isNotEmpty(elementDefs)) {
        for (AtlasEnumElementDef elementDef : elementDefs) {
            if (StringUtils.equalsIgnoreCase(elementDef.getValue(), elemValue)) {
                ret = elementDef;
                break;
            }
        }
    }

    return ret;
}
 
Example 14
Source File: AtlasStructDef.java    From atlas with Apache License 2.0 5 votes vote down vote up
public static AtlasAttributeDef findAttribute(Collection<AtlasAttributeDef> attributeDefs, String attrName) {
    AtlasAttributeDef ret = null;

    if (CollectionUtils.isNotEmpty(attributeDefs)) {
        for (AtlasAttributeDef attributeDef : attributeDefs) {
            if (StringUtils.equalsIgnoreCase(attributeDef.getName(), attrName)) {
                ret = attributeDef;
                break;
            }
        }
    }

    return ret;
}
 
Example 15
Source File: AtlasStructDef.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
public static AtlasAttributeDef findAttribute(Collection<AtlasAttributeDef> attributeDefs, String attrName) {
    AtlasAttributeDef ret = null;

    if (CollectionUtils.isNotEmpty(attributeDefs)) {
        for (AtlasAttributeDef attributeDef : attributeDefs) {
            if (StringUtils.equalsIgnoreCase(attributeDef.getName(), attrName)) {
                ret = attributeDef;
                break;
            }
        }
    }

    return ret;
}
 
Example 16
Source File: Configuration.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Get the value of the <code>name</code> property as a <code>boolean</code>.
 * If no such property is specified, or if the specified value is not a valid
 * <code>boolean</code>, then <code>defaultValue</code> is returned.
 *
 * @param name property name.
 * @param defaultValue default value.
 * @return property value as a <code>boolean</code>,
 *         or <code>defaultValue</code>.
 */
public boolean getBoolean(String name, boolean defaultValue) {
	String valueString = getTrimmed(name);
	if (null == valueString || valueString.isEmpty()) {
		return defaultValue;
	}

	if (StringUtils.equalsIgnoreCase("true", valueString))
		return true;
	else if (StringUtils.equalsIgnoreCase("false", valueString))
		return false;
	else return defaultValue;
}
 
Example 17
Source File: Configuration.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Get the value of the <code>name</code> property as a <code>boolean</code>.
 * If no such property is specified, or if the specified value is not a valid
 * <code>boolean</code>, then <code>defaultValue</code> is returned.
 *
 * @param name property name.
 * @param defaultValue default value.
 * @return property value as a <code>boolean</code>,
 *         or <code>defaultValue</code>.
 */
public boolean getBoolean(String name, boolean defaultValue) {
	String valueString = getTrimmed(name);
	if (null == valueString || valueString.isEmpty()) {
		return defaultValue;
	}

	if (StringUtils.equalsIgnoreCase("true", valueString))
		return true;
	else if (StringUtils.equalsIgnoreCase("false", valueString))
		return false;
	else return defaultValue;
}
 
Example 18
Source File: Configuration.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Get the value of the <code>name</code> property as a <code>boolean</code>.
 * If no such property is specified, or if the specified value is not a valid
 * <code>boolean</code>, then <code>defaultValue</code> is returned.
 *
 * @param name property name.
 * @param defaultValue default value.
 * @return property value as a <code>boolean</code>,
 *         or <code>defaultValue</code>.
 */
public boolean getBoolean(String name, boolean defaultValue) {
	String valueString = getTrimmed(name);
	if (null == valueString || valueString.isEmpty()) {
		return defaultValue;
	}

	if (StringUtils.equalsIgnoreCase("true", valueString))
		return true;
	else if (StringUtils.equalsIgnoreCase("false", valueString))
		return false;
	else return defaultValue;
}
 
Example 19
Source File: AtlasStructDef.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
@JsonIgnore
public boolean isConstraintType(String name) {
    return StringUtils.equalsIgnoreCase(name, this.type);
}
 
Example 20
Source File: AtlasStructDef.java    From atlas with Apache License 2.0 4 votes vote down vote up
@JsonIgnore
public boolean isConstraintType(String name) {
    return StringUtils.equalsIgnoreCase(name, this.type);
}