/** * Determines if the id of the referenced entity equals the given id. * * @param id the id to check * @return <tt>true</tt> if the id of the referenced entity equals the given id, <tt>false</tt> otherwise */ public boolean containsId(String id) { return Strings.areEqual(this.id, id); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!(obj instanceof TableColumn)) { return false; } return Strings.areEqual(((TableColumn) obj).name, name); }
/** * Gets the list of all named queries which matched this entity. * * @param queryName the name of the query to check * @return the list of named queries which matched this entity. */ public boolean isMatchedNamedQuery(String queryName) { return Arrays.stream(matchedNamedQueries).anyMatch(query -> Strings.areEqual(query, queryName)); }
protected boolean checkForEquality(String left, String right) { if ("0".equals(left) && "0.0".equals(right)) { return true; } if ("1".equals(left) && "1.000".equals(right)) { return true; } if (left != null && ("'" + left + "'").equals(right)) { return true; } if (left == null && "''".equals(right)) { return true; } return Strings.areEqual(left, right); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (!(obj instanceof Property)) { return false; } return descriptor.equals(((Property) obj).descriptor) && Strings.areEqual(name, ((Property) obj).name); }
/** * Returns the key with the given name. * * @param indexName the name of the key or index * @return the key with the given name or <tt>null</tt> if no such key exists */ public Key getKey(String indexName) { for (Key key : keys) { if (Strings.areEqual(indexName, key.getName())) { return key; } } return null; }
/** * Returns the foreign key with the given name. * * @param name the name of the foreign key * @return the foreign key with the given name or <tt>null</tt> if no such key exists */ public ForeignKey getForeignKey(String name) { for (ForeignKey key : foreignKeys) { if (Strings.areEqual(name, key.getName())) { return key; } } return null; }
protected QueryBuilder compileToken(String field, String value) { if (value.endsWith("*")) { // + 1 to compensate for the "*" in the string if (value.length() >= EXPANSION_TOKEN_MIN_LENGTH + 1 && Strings.areEqual(field, defaultField)) { return compileTokenWithAsterisk(value.substring(0, value.length() - 1)); } else if (value.length() == 1) { return null; } else { value = value.substring(0, value.length() - 1); } } if ("id".equals(field)) { field = "_id"; } return createTokenConstraint(field, value); }
private boolean propertyAlreadyExists(List<Property> props, Property check) { for (Property prop : props) { if (Strings.areEqual(prop.getName(), check.getName())) { return true; } } return false; }
private Function<String, Value> makeContext(ContextInfo[] info) { if (info == null || info.length == 0) { return EMPTY_CONTEXT; } return key -> { for (int i = 0; i < info.length; i++) { if (Strings.areEqual(info[i].getKey(), key)) { return info[i].getValue(); } } return Value.EMPTY; }; }
@Override public void handle(Incident incident) throws Exception { synchronized (incidents) { boolean unique = true; Iterator<Incident> iter = incidents.iterator(); while (iter.hasNext()) { if (Strings.areEqual(iter.next().getLocation(), incident.getLocation())) { iter.remove(); unique = false; } } incidents.add(0, incident); numIncidents.inc(); if (unique) { numUniqueIncidents.inc(); } while (incidents.size() > maxErrors) { incidents.remove(incidents.size() - 1); } } }
private TableColumn findColumn(Table other, String name) { String effectiveName = dialect.translateColumnName(name); for (TableColumn col : other.getColumns()) { if (Strings.areEqual(col.getName(), effectiveName)) { return col; } } return null; }
/** * Generates the mapping used by this property * * @param builder the builder used to generate JSON * @throws IOException in case of an io error while generating the mapping */ @Override public void addMappingProperties(XContentBuilder builder) throws IOException { super.addMappingProperties(builder); builder.startObject("properties"); builder.startObject(KEY); builder.field("type", "keyword"); if (Strings.areEqual("true", includeInAll.getValue())) { builder.field("copy_to", "custom_all"); } builder.endObject(); builder.startObject(VALUE); builder.field("type", super.getMappingType()); if (Strings.areEqual("true", includeInAll.getValue())) { builder.field("copy_to", "custom_all"); } builder.endObject(); builder.endObject(); }
private void importProperty(Map<String, Translation> modifyableTranslationsCopy, String lang, String file, String key, String value) { Translation entry = modifyableTranslationsCopy.computeIfAbsent(key, Translation::new); entry.setAutocreated(false); String previous = entry.addTranslation(lang, value); if (previous != null && !Strings.areEqual(previous, value) && !Sirius.isCustomizationResource(file)) { Babelfish.LOG.WARN("Overriding translation for '%s' (%s) in language %s: '%s' --> '%s'", key, file, lang, previous, value); } }
/** * Executes the schema change action with the given id. * * @param id the id of the action to execute * @return the action itself to fetch an error message in case of database problems */ @Nullable public SchemaUpdateAction executeSchemaUpdateAction(String id) { for (SchemaUpdateAction a : getSchemaUpdateActions()) { if (Strings.areEqual(id, a.getId())) { a.execute(getDatabase(a.getRealm())); return a; } } return null; }
/** * If the entity being queries is routed, we try to preset the correct routing value or to disable routing. * <p> * This is used by {@link sirius.search.ForeignKey} as if cannot know if and how an entity is routed. * Therefore this method checks if by coincidence the given field and value (which is used by the foreign key * to filter entities) is also used to route those entities. If this is true, the routing is applied, * otherwise {@link #deliberatelyUnrouted()} is called. * * @param field the field for which a filter value is available * @param value the value of the field * @return the query itself for fluent method calls */ protected Query<E> autoRoute(String field, String value) { EntityDescriptor descriptor = indexAccess.getDescriptor(clazz); if (!descriptor.hasRouting()) { return this; } if (Strings.areEqual(descriptor.getRouting(), field)) { routing(value); } else { deliberatelyUnrouted(); } return this; }
private Table createTable(EntityDescriptor ed) { Table table = new Table(ed); table.setName(ed.getRelationName()); if (getDatabase(ed.getRealm()).hasCapability(Capability.LOWER_CASE_TABLE_NAMES)) { if (!Strings.areEqual(ed.getRelationName(), ed.getRelationName().toLowerCase())) { OMA.LOG.WARN("Warning %s uses %s as table name which is not all lowercase." + " This might lead to trouble with the type of DBMS you are using!", ed.getType().getName(), ed.getRelationName()); } } collectColumns(table, ed); collectKeys(table, ed); return table; }
@Override public void contributeToTable(Table table) { table.getColumns().add(new TableColumn(this, Types.BIGINT)); if (SQLEntity.class.isAssignableFrom(getReferencedType()) && Strings.areEqual(getDescriptor().getRealm(), getReferencedDescriptor().getRealm())) { ForeignKey fk = new ForeignKey(); fk.setName("fk_" + descriptor.getRelationName() + "_" + getPropertyName() + "_" + referencedDescriptor.getRelationName()); fk.setForeignTable(getReferencedDescriptor().getRelationName()); fk.addForeignColumn(1, SQLEntity.ID.getName()); fk.addColumn(1, getPropertyName()); table.getForeignKeys().add(fk); } }
protected String checkColumnSettings(TableColumn target, TableColumn current) { if (!areTypesEqual(target.getType(), current.getType())) { return NLS.fmtr("BasicDatabaseDialect.differentTypes") .set(KEY_TARGET, SchemaTool.getJdbcTypeName(target.getType())) .set(KEY_CURRENT, SchemaTool.getJdbcTypeName(current.getType())) .format(); } if (areTypesEqual(Types.CHAR, target.getType()) && !Strings.areEqual(target.getLength(), current.getLength())) { return NLS.fmtr("BasicDatabaseDialect.differentLength") .set(KEY_TARGET, target.getLength()) .set(KEY_CURRENT, current.getLength()) .format(); } if (areTypesEqual(Types.DECIMAL, target.getType())) { if (!Strings.areEqual(target.getPrecision(), current.getPrecision())) { return NLS.fmtr("BasicDatabaseDialect.differentPrecision") .set(KEY_TARGET, target.getPrecision()) .set(KEY_CURRENT, current.getPrecision()) .format(); } if (!Strings.areEqual(target.getScale(), current.getScale())) { return NLS.fmtr("BasicDatabaseDialect.differentScale") .set(KEY_TARGET, target.getScale()) .set(KEY_CURRENT, current.getScale()) .format(); } } return null; }