List of usage examples for java.util Arrays equals
public static boolean equals(Object[] a, Object[] a2)
From source file:com.ables.pix.model.Album.java
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; final Album other = (Album) obj; if (creationDate == null) { if (other.creationDate != null) return false; } else if (!creationDate.equals(other.creationDate)) return false; if (description == null) { if (other.description != null) return false; } else if (!description.equals(other.description)) return false; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; if (!Arrays.equals(labels, other.labels)) return false; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; if (user == null) { if (other.user != null) return false; } else if (!user.equals(other.user)) return false; return true;/*from www. j ava2s .co m*/ }
From source file:com.moz.fiji.schema.filter.OperatorRowFilter.java
/** {@inheritDoc} */ @Override/*ww w . ja va 2 s . c o m*/ public boolean equals(Object object) { if ((null == object) || (object.getClass() != getClass())) { return false; } final OperatorRowFilter that = (OperatorRowFilter) object; return Objects.equal(this.mOperator, that.mOperator) && Arrays.equals(this.mFilters, that.mFilters); }
From source file:org.tonguetied.web.KeywordValidator.java
/** * This validation method checks if the set of {@link Translation}s for a * {@link Keyword} contains duplicate entries of the business key. * // w w w . ja v a2s . c o m * @param translations the set of {@link Translation}s to validate * @param errors contextual state about the validation process (never null) */ protected void validateDuplicates(SortedSet<Translation> translations, Errors errors) { Collection<Translation> output; TranslationPredicate predicate; List<FieldError> fieldErrors; if (translations.size() > 1) { for (Translation translation : translations) { predicate = new TranslationPredicate(translation.getBundle(), translation.getCountry(), translation.getLanguage()); output = CollectionUtils.select(translations, predicate); if (output.size() > 1) { final String[] errorArgs = new String[] { getLanguageName(translation.getLanguage()), getCountryName(translation.getCountry()), getBundleName(translation.getBundle()) }; fieldErrors = errors.getFieldErrors(FIELD_TRANSLATIONS); boolean containsError = false; for (FieldError error : fieldErrors) { containsError = containsError || Arrays.equals(error.getArguments(), errorArgs); } if (!containsError) { errors.rejectValue(FIELD_TRANSLATIONS, "error.duplicate.translations", errorArgs, "default"); } } } } }
From source file:net.sf.taverna.t2.reference.RegisterLargeByteArrayTest.java
@Test public void register1mByteArray() throws Exception { byte[] bytes = readBinaryData("1m.bin"); ApplicationContext context = new RavenAwareClassPathXmlApplicationContext( "registrationAndTraversalTestContext.xml"); ReferenceService rs = (ReferenceService) context.getBean("t2reference.service.referenceService"); T2Reference reference = rs.register(bytes, 0, true, dummyContext); Object returnedObject = rs.renderIdentifier(reference, Object.class, dummyContext); byte[] newbytes = (byte[]) returnedObject; assertEquals("There bytes should be of the same length", bytes.length, newbytes.length); //assertNotSame("They shouldn't be the same actual object",bytes, newbytes); assertTrue("The bytes should have the same content", Arrays.equals(bytes, newbytes)); }
From source file:it.geosolutions.geostore.core.security.password.GeoStorePBEPasswordEncoder.java
@Override protected CharArrayPasswordEncoder createCharEncoder() { byte[] password = lookupPasswordFromKeyStore(); char[] chars = toChars(password); byteEncrypter = new StandardPBEByteEncryptor(); byteEncrypter.setPasswordCharArray(chars); if (getProviderName() != null && !getProviderName().isEmpty()) { byteEncrypter.setProviderName(getProviderName()); }/* w w w. java 2 s .co m*/ byteEncrypter.setAlgorithm(getAlgorithm()); return new CharArrayPasswordEncoder() { @Override public boolean isPasswordValid(String encPass, char[] rawPass, Object salt) { byte[] decoded = Base64.decode(encPass.getBytes()); byte[] decrypted = byteEncrypter.decrypt(decoded); char[] chars = toChars(decrypted); try { return Arrays.equals(chars, rawPass); } finally { scramble(decrypted); scramble(chars); } } @Override public String encodePassword(char[] rawPass, Object salt) { byte[] bytes = toBytes(rawPass); try { return new String(Base64.encode(byteEncrypter.encrypt(bytes))); } finally { scramble(bytes); } } }; }
From source file:org.opensafety.hishare.managers.implementation.remoting.ParcelManagerImpl.java
public boolean verifyParcelAvailable(String parcelId, String parcelPassword) { if (parcelDao.verifyParcelAvailable(parcelId)) { Parcel parcel = parcelDao.getById(parcelId); try {/*ww w . ja va 2s.co m*/ byte[] hashedPassword = encryption.hashPassword(parcelPassword, parcel.getSalt()); return Arrays.equals(hashedPassword, parcel.getHashedPassword()); } catch (CryptographyException e) { log.error("Password Matching Threw Exception!", e); return false; } } return false; }
From source file:org.brekka.stillingar.example.FieldTypesXmlBeansTest.java
/** * /* w w w . j a v a 2s . c om*/ */ private void verify() throws Exception { ConfiguredFieldTypes t = configuredFieldTypes; assertEquals(new URI(testing.getAnyURI()), t.getUri()); assertEquals(testing.getBoolean(), t.isBooleanPrimitive()); assertEquals(Byte.valueOf(testing.getByte()), t.getByteValue()); assertEquals(testing.getByte(), t.getBytePrimitive()); assertEquals(testing.getDate(), t.getDateAsCalendar()); assertEquals(testing.getDate().getTime(), t.getDateAsDate()); assertEquals(testing.getDateTime(), t.getDateTimeAsCalendar()); assertEquals(testing.getDateTime().getTime(), t.getDateTimeAsDate()); assertEquals(testing.getDecimal(), t.getDecimal()); assertEquals(Double.valueOf(testing.getDouble()), t.getDoubleValue()); assertEquals(testing.getDouble(), t.getDoublePrimitive(), 1d); assertEquals(testing.getFloat(), t.getFloatPrimitive(), 1f); assertEquals(Float.valueOf(testing.getFloat()), t.getFloatValue()); assertEquals(testing.getInt(), t.getIntPrimitive()); assertEquals(Integer.valueOf(testing.getInt()), t.getIntValue()); assertEquals(testing.getLanguage(), t.getLanguage().toString()); assertEquals(testing.getLong(), t.getLongPrimitive()); assertEquals(Long.valueOf(testing.getLong()), t.getLongValue()); assertEquals(testing.getShort(), t.getShortPrimitive()); assertEquals(Short.valueOf(testing.getShort()), t.getShortValue()); assertEquals(testing.getString(), t.getString()); assertEquals(testing.getTime(), t.getTimeAsCalendar()); assertEquals(testing.getPeriod().toString(), t.getPeriod().toString()); assertEquals(new DateTime(testing.getDateTime(), ISOChronology.getInstance()), t.getDateTime()); assertEquals(new LocalDate(testing.getDate(), ISOChronology.getInstance()), t.getLocalDate()); assertEquals(new LocalTime(testing.getTime(), ISOChronology.getInstance()), t.getLocalTime()); assertTrue(Arrays.equals(t.getBinary(), testing.getBinary())); assertEquals(UUID.fromString(testing.getUUID()), t.getUuid()); assertTrue(t.getTestingObject() instanceof Testing); assertNotNull(t.getTestingElement()); assertNotNull(t.getRoot()); }
From source file:ee.ria.xroad.common.conf.globalconf.ConfigurationLocation.java
@Override public boolean equals(Object obj) { if (!(obj instanceof ConfigurationLocation)) { return false; }/*from ww w . ja v a 2 s .c om*/ ConfigurationLocation that = (ConfigurationLocation) obj; if (!this.getDownloadURL().equals(that.getDownloadURL())) { return false; } List<byte[]> thisCerts = this.verificationCerts; List<byte[]> thatCerts = that.verificationCerts; if (thisCerts.size() != thatCerts.size()) { return false; } for (int i = 0; i < thisCerts.size(); i++) { if (!Arrays.equals(thisCerts.get(i), thatCerts.get(i))) { return false; } } return true; }
From source file:com.jivesoftware.os.amza.api.partition.PartitionName.java
@Override public boolean equals(Object obj) { if (obj == null) { return false; }/*from ww w. j a va 2s . com*/ if (getClass() != obj.getClass()) { return false; } final PartitionName other = (PartitionName) obj; if (this.systemPartition != other.systemPartition) { return false; } if (!Arrays.equals(this.ringName, other.ringName)) { return false; } return Arrays.equals(this.name, other.name); }
From source file:com.day.cq.wcm.foundation.forms.MergedValueMap.java
private Object read(String key) { Object value = null;//from ww w . j a va 2s .com boolean firstResource = true; boolean isArray = false; for (Resource resource : resources) { ValueMap map = resource.adaptTo(ValueMap.class); if (map != null) { if (firstResource) { value = map.get(key); if (value == null) break; isArray = value.getClass().isArray(); } else { Object newValue = map.get(key); if (newValue == null) { value = null; break; } boolean newIsArray = newValue.getClass().isArray(); if (isArray != newIsArray || (isArray && !Arrays.equals((Object[]) value, (Object[]) newValue)) || (!isArray && !ObjectUtils.equals(value, newValue))) { // break if: // - one of the values is single and the other mutiple // - or both are mutliple but the values do not match // - or both are single but do not match value = null; break; } } } firstResource = false; } cache.put(key, value); return value; }