@Override public void read(JSONObject object) throws JSONException { super.read(object); setPushToken(object.getString(PUSH_TOKEN)); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } PushInstallationLog pushInstallationLog = (PushInstallationLog) o; return pushToken != null ? pushToken.equals(pushInstallationLog.pushToken) : pushInstallationLog.pushToken == null; }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (properties != null ? properties.hashCode() : 0); return result; } }
@Override public void read(JSONObject object) throws JSONException { if (!object.getString(TYPE).equals(getType())) { throw new JSONException("Invalid type"); } setTimestamp(JSONDateUtils.toDate(object.getString(TIMESTAMP))); if (object.has(SID)) { setSid(UUID.fromString(object.getString(SID))); } setDistributionGroupId(object.optString(DISTRIBUTION_GROUP_ID, null)); setUserId(object.optString(USER_ID, null)); if (object.has(DEVICE)) { Device device = new Device(); device.read(object.getJSONObject(DEVICE)); setDevice(device); } }
a.addTransmissionTarget("a"); checkNotEquals(a, b); b.addTransmissionTarget("a"); checkEquals(a, b); a.setTimestamp(new Date(1)); checkNotEquals(a, b); b.setTimestamp(new Date(1)); checkEquals(a, b); a.setSid(sid1); checkNotEquals(a, b); b.setSid(sid2); checkNotEquals(a, b); b.setSid(sid1); checkEquals(a, b); a.setDistributionGroupId(distributionGroupId1); checkNotEquals(a, b); b.setDistributionGroupId(distributionGroupId2); checkNotEquals(a, b); b.setDistributionGroupId(distributionGroupId1); checkEquals(a, b); a.setUserId(userId1); checkNotEquals(a, b); b.setUserId(userId2); checkNotEquals(a, b); b.setUserId(userId1);
@Override public void write(JSONStringer writer) throws JSONException { super.write(writer); writeProperties(writer, getProperties()); }
@Test public void writeNullDeviceTest() throws JSONException { JSONStringer mockJsonStringer = mock(JSONStringer.class); when(mockJsonStringer.key(anyString())).thenReturn(mockJsonStringer); when(mockJsonStringer.value(anyString())).thenReturn(mockJsonStringer); AbstractLog mockLog = new MockLog(); mockLog.setTimestamp(new Date()); mockLog.write(mockJsonStringer); verify(mockJsonStringer, never()).key(AbstractLog.DEVICE); }
@Override public void write(JSONStringer writer) throws JSONException { super.write(writer); JSONUtils.writeMap(writer, PROPERTIES, getProperties()); }
@Override public void read(JSONObject object) throws JSONException { super.read(object); setProperties(JSONUtils.readMap(object, PROPERTIES)); }
@Override public void write(JSONStringer writer) throws JSONException { super.write(writer); JSONUtils.writeStringArray(writer, SERVICES, getServices()); }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (services != null ? services.hashCode() : 0); return result; } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } CustomPropertiesLog that = (CustomPropertiesLog) o; return properties != null ? properties.equals(that.properties) : that.properties == null; }
@Override public void read(JSONObject object) throws JSONException { super.read(object); setServices(JSONUtils.readStringArray(object, SERVICES)); }
@Override public void write(JSONStringer writer) throws JSONException { super.write(writer); writer.key(PUSH_TOKEN).value(getPushToken()); }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (properties != null ? properties.hashCode() : 0); return result; } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } LogWithProperties that = (LogWithProperties) o; return properties != null ? properties.equals(that.properties) : that.properties == null; }
@Override public void read(JSONObject object) throws JSONException { super.read(object); setProperties(readProperties(object)); }
@Override public void write(JSONStringer writer) throws JSONException { super.write(writer); JSONUtils.write(writer, ID, getId()); JSONUtils.write(writer, ERROR_ID, getErrorId()); JSONUtils.write(writer, CONTENT_TYPE, getContentType()); JSONUtils.write(writer, FILE_NAME, getFileName()); JSONUtils.write(writer, DATA, Base64.encodeToString(getData(), Base64.NO_WRAP)); }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (pushToken != null ? pushToken.hashCode() : 0); return result; } }
@Override @SuppressWarnings("SimplifiableIfStatement") public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } StartServiceLog that = (StartServiceLog) o; return services != null ? services.equals(that.services) : that.services == null; }