Example usage for org.apache.hadoop.util StringUtils equalsIgnoreCase

List of usage examples for org.apache.hadoop.util StringUtils equalsIgnoreCase

Introduction

In this page you can find the example usage for org.apache.hadoop.util StringUtils equalsIgnoreCase.

Prototype

public static boolean equalsIgnoreCase(String s1, String s2) 

Source Link

Document

Compare strings locale-freely by using String#equalsIgnoreCase.

Usage

From source file:org.apache.atlas.model.typedef.AtlasEnumDef.java

License:Apache License

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);
            }/*  w w  w .  j  ava2s .  c o m*/
        }
    }
    tmpList.add(new AtlasEnumElementDef(elementDef));

    this.elementDefs = tmpList;
}

From source file:org.apache.atlas.model.typedef.AtlasEnumDef.java

License:Apache License

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);
            }/*from  ww  w. ja  va 2s. c  om*/
        }

        this.elementDefs = tmpList;
    }
}

From source file:org.apache.atlas.model.typedef.AtlasEnumDef.java

License:Apache License

private static AtlasEnumElementDef findElement(List<AtlasEnumElementDef> elementDefs, String elemValue) {
    AtlasEnumElementDef ret = null;/*from   ww  w. j a  va  2 s.  co m*/

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

    return ret;
}

From source file:org.apache.atlas.model.typedef.AtlasStructDef.java

License:Apache License

public void addAttribute(AtlasAttributeDef attributeDef) {
    if (attributeDef == null) {
        return;//from w w  w. j av  a2  s  .  c  om
    }

    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;
}

From source file:org.apache.atlas.model.typedef.AtlasStructDef.java

License:Apache License

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);
            }/*from  w  w  w  .  ja va 2s  .  co m*/
        }

        this.attributeDefs = tmpList;
    }
}

From source file:org.apache.atlas.model.typedef.AtlasStructDef.java

License:Apache License

public static AtlasAttributeDef findAttribute(Collection<AtlasAttributeDef> attributeDefs, String attrName) {
    AtlasAttributeDef ret = null;/*  w  w w.  ja  va2  s  . c  o m*/

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

    return ret;
}

From source file:org.apache.atlas.security.InMemoryJAASConfigurationTest.java

License:Apache License

public void testGetAppConfigurationEntryStringForKafkaClient() {
    AppConfigurationEntry[] entries = Configuration.getConfiguration().getAppConfigurationEntry("KafkaClient");
    Assert.assertNotNull(entries);/* w w w  . j av  a  2  s.c o  m*/
    Assert.assertEquals(1, entries.length);
    String principal = (String) entries[0].getOptions().get("principal");
    Assert.assertNotNull(principal);
    String[] components = principal.split("[/@]");
    Assert.assertEquals(3, components.length);
    Assert.assertEquals(false, StringUtils.equalsIgnoreCase(components[1], "_HOST"));

}

From source file:org.apache.atlas.security.InMemoryJAASConfigurationTest.java

License:Apache License

public void testGetAppConfigurationEntryStringForMyClient() {
    AppConfigurationEntry[] entries = Configuration.getConfiguration().getAppConfigurationEntry("myClient");
    Assert.assertNotNull(entries);//from w  w w. ja  v  a 2s .  c om
    Assert.assertEquals(2, entries.length);
    String principal = (String) entries[0].getOptions().get("principal");
    Assert.assertNotNull(principal);
    String[] components = principal.split("[/@]");
    Assert.assertEquals(3, components.length);
    Assert.assertEquals(true, StringUtils.equalsIgnoreCase(components[1], "abcd"));

    principal = (String) entries[1].getOptions().get("principal");
    Assert.assertNotNull(principal);
    components = principal.split("[/@]");
    Assert.assertEquals(2, components.length);
}

From source file:org.apache.ranger.tagsync.source.atlas.AtlasNotificationMapper.java

License:Apache License

static private Map<String, ServiceTags> buildServiceTags(List<AtlasEntityWithTraits> entitiesWithTraits)
        throws Exception {

    Map<String, ServiceTags> ret = new HashMap<String, ServiceTags>();

    for (AtlasEntityWithTraits element : entitiesWithTraits) {
        buildServiceTags(element, ret);//from www. jav  a2  s  . c  om
    }

    // Remove duplicate tag definitions
    if (CollectionUtils.isNotEmpty(ret.values())) {
        for (ServiceTags serviceTag : ret.values()) {
            if (MapUtils.isNotEmpty(serviceTag.getTagDefinitions())) {
                Map<String, RangerTagDef> uniqueTagDefs = new HashMap<String, RangerTagDef>();

                for (RangerTagDef tagDef : serviceTag.getTagDefinitions().values()) {
                    RangerTagDef existingTagDef = uniqueTagDefs.get(tagDef.getName());

                    if (existingTagDef == null) {
                        uniqueTagDefs.put(tagDef.getName(), tagDef);
                    } else {
                        if (CollectionUtils.isNotEmpty(tagDef.getAttributeDefs())) {
                            for (RangerTagAttributeDef tagAttrDef : tagDef.getAttributeDefs()) {
                                boolean attrDefExists = false;

                                if (CollectionUtils.isNotEmpty(existingTagDef.getAttributeDefs())) {
                                    for (RangerTagAttributeDef existingTagAttrDef : existingTagDef
                                            .getAttributeDefs()) {
                                        if (StringUtils.equalsIgnoreCase(existingTagAttrDef.getName(),
                                                tagAttrDef.getName())) {
                                            attrDefExists = true;
                                            break;
                                        }
                                    }
                                }

                                if (!attrDefExists) {
                                    existingTagDef.getAttributeDefs().add(tagAttrDef);
                                }
                            }
                        }
                    }
                }

                serviceTag.getTagDefinitions().clear();
                for (RangerTagDef tagDef : uniqueTagDefs.values()) {
                    serviceTag.getTagDefinitions().put(tagDef.getId(), tagDef);
                }
            }
        }
    }

    return ret;
}