@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getServiceErrorId() == null) ? 0 : getServiceErrorId().hashCode()); hashCode = prime * hashCode + ((getStackId() == null) ? 0 : getStackId().hashCode()); hashCode = prime * hashCode + ((getInstanceId() == null) ? 0 : getInstanceId().hashCode()); hashCode = prime * hashCode + ((getType() == null) ? 0 : getType().hashCode()); hashCode = prime * hashCode + ((getMessage() == null) ? 0 : getMessage().hashCode()); hashCode = prime * hashCode + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode()); return hashCode; }
/** * <p> * When the error occurred. * </p> * * @param createdAt * When the error occurred. * @return Returns a reference to this object so that method calls can be chained together. */ public ServiceError withCreatedAt(String createdAt) { setCreatedAt(createdAt); return this; }
public ServiceError unmarshall(JsonUnmarshallerContext context) throws Exception { ServiceError serviceError = new ServiceError(); if (context.testExpression("ServiceErrorId", targetDepth)) { context.nextToken(); serviceError.setServiceErrorId(context.getUnmarshaller(String.class).unmarshall(context)); serviceError.setStackId(context.getUnmarshaller(String.class).unmarshall(context)); serviceError.setInstanceId(context.getUnmarshaller(String.class).unmarshall(context)); serviceError.setType(context.getUnmarshaller(String.class).unmarshall(context)); serviceError.setMessage(context.getUnmarshaller(String.class).unmarshall(context)); serviceError.setCreatedAt(context.getUnmarshaller(String.class).unmarshall(context));
@Test public void test1() throws Exception { ServiceError serviceError = new ServiceError("Noby Stiles", "good footballer"); serviceError.setName("Noby Stiles"); serviceError.setDescription("good footballer"); String json = new ObjectMapper().writeValueAsString(serviceError); SimpleModule simpleModule = new SimpleModule(); simpleModule.addDeserializer(ServiceError.class, new ServiceErrorSerializer()); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.registerModule(simpleModule); ServiceError serviceError2 = objectMapper.readValue(json, ServiceError.class); assertNotNull(serviceError2); assertEquals("Noby Stiles", serviceError2.getName()); }
public class ServiceErrorSerializer extends JsonDeserializer<ServiceError> { @Override public ServiceError deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { ServiceError serviceError = new ServiceError(null, null); ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); serviceError.setName(node.get("name").asText()); serviceError.setDescription(node.get("description").asText()); return serviceError; } }
try { } catch(Throwable t) { return new ServiceError(109L,"RunTime Error:"+t.getMessage()); }
public ServiceError unmarshall(JsonUnmarshallerContext context) throws Exception { ServiceError serviceError = new ServiceError(); if (context.testExpression("ServiceErrorId", targetDepth)) { context.nextToken(); serviceError.setServiceErrorId(context.getUnmarshaller(String.class).unmarshall(context)); serviceError.setStackId(context.getUnmarshaller(String.class).unmarshall(context)); serviceError.setInstanceId(context.getUnmarshaller(String.class).unmarshall(context)); serviceError.setType(context.getUnmarshaller(String.class).unmarshall(context)); serviceError.setMessage(context.getUnmarshaller(String.class).unmarshall(context)); serviceError.setCreatedAt(context.getUnmarshaller(String.class).unmarshall(context));
return false; ServiceError other = (ServiceError) obj; if (other.getServiceErrorId() == null ^ this.getServiceErrorId() == null) return false; if (other.getServiceErrorId() != null && other.getServiceErrorId().equals(this.getServiceErrorId()) == false) return false; if (other.getStackId() == null ^ this.getStackId() == null) return false; if (other.getStackId() != null && other.getStackId().equals(this.getStackId()) == false) return false; if (other.getInstanceId() == null ^ this.getInstanceId() == null) return false; if (other.getInstanceId() != null && other.getInstanceId().equals(this.getInstanceId()) == false) return false; if (other.getType() == null ^ this.getType() == null) return false; if (other.getType() != null && other.getType().equals(this.getType()) == false) return false; if (other.getMessage() == null ^ this.getMessage() == null) return false; if (other.getMessage() != null && other.getMessage().equals(this.getMessage()) == false) return false; if (other.getCreatedAt() == null ^ this.getCreatedAt() == null) return false; if (other.getCreatedAt() != null && other.getCreatedAt().equals(this.getCreatedAt()) == false) return false; return true;
/** * <p> * When the error occurred. * </p> * * @param createdAt * When the error occurred. * @return Returns a reference to this object so that method calls can be chained together. */ public ServiceError withCreatedAt(String createdAt) { setCreatedAt(createdAt); return this; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getServiceErrorId() != null) sb.append("ServiceErrorId: ").append(getServiceErrorId()).append(","); if (getStackId() != null) sb.append("StackId: ").append(getStackId()).append(","); if (getInstanceId() != null) sb.append("InstanceId: ").append(getInstanceId()).append(","); if (getType() != null) sb.append("Type: ").append(getType()).append(","); if (getMessage() != null) sb.append("Message: ").append(getMessage()).append(","); if (getCreatedAt() != null) sb.append("CreatedAt: ").append(getCreatedAt()); sb.append("}"); return sb.toString(); }
/** * Marshall the given parameter object. */ public void marshall(ServiceError serviceError, ProtocolMarshaller protocolMarshaller) { if (serviceError == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(serviceError.getServiceErrorId(), SERVICEERRORID_BINDING); protocolMarshaller.marshall(serviceError.getStackId(), STACKID_BINDING); protocolMarshaller.marshall(serviceError.getInstanceId(), INSTANCEID_BINDING); protocolMarshaller.marshall(serviceError.getType(), TYPE_BINDING); protocolMarshaller.marshall(serviceError.getMessage(), MESSAGE_BINDING); protocolMarshaller.marshall(serviceError.getCreatedAt(), CREATEDAT_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getServiceErrorId() == null) ? 0 : getServiceErrorId().hashCode()); hashCode = prime * hashCode + ((getStackId() == null) ? 0 : getStackId().hashCode()); hashCode = prime * hashCode + ((getInstanceId() == null) ? 0 : getInstanceId().hashCode()); hashCode = prime * hashCode + ((getType() == null) ? 0 : getType().hashCode()); hashCode = prime * hashCode + ((getMessage() == null) ? 0 : getMessage().hashCode()); hashCode = prime * hashCode + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode()); return hashCode; }
return false; ServiceError other = (ServiceError) obj; if (other.getServiceErrorId() == null ^ this.getServiceErrorId() == null) return false; if (other.getServiceErrorId() != null && other.getServiceErrorId().equals(this.getServiceErrorId()) == false) return false; if (other.getStackId() == null ^ this.getStackId() == null) return false; if (other.getStackId() != null && other.getStackId().equals(this.getStackId()) == false) return false; if (other.getInstanceId() == null ^ this.getInstanceId() == null) return false; if (other.getInstanceId() != null && other.getInstanceId().equals(this.getInstanceId()) == false) return false; if (other.getType() == null ^ this.getType() == null) return false; if (other.getType() != null && other.getType().equals(this.getType()) == false) return false; if (other.getMessage() == null ^ this.getMessage() == null) return false; if (other.getMessage() != null && other.getMessage().equals(this.getMessage()) == false) return false; if (other.getCreatedAt() == null ^ this.getCreatedAt() == null) return false; if (other.getCreatedAt() != null && other.getCreatedAt().equals(this.getCreatedAt()) == false) return false; return true;
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getServiceErrorId() != null) sb.append("ServiceErrorId: ").append(getServiceErrorId()).append(","); if (getStackId() != null) sb.append("StackId: ").append(getStackId()).append(","); if (getInstanceId() != null) sb.append("InstanceId: ").append(getInstanceId()).append(","); if (getType() != null) sb.append("Type: ").append(getType()).append(","); if (getMessage() != null) sb.append("Message: ").append(getMessage()).append(","); if (getCreatedAt() != null) sb.append("CreatedAt: ").append(getCreatedAt()); sb.append("}"); return sb.toString(); }
/** * Marshall the given parameter object. */ public void marshall(ServiceError serviceError, ProtocolMarshaller protocolMarshaller) { if (serviceError == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(serviceError.getServiceErrorId(), SERVICEERRORID_BINDING); protocolMarshaller.marshall(serviceError.getStackId(), STACKID_BINDING); protocolMarshaller.marshall(serviceError.getInstanceId(), INSTANCEID_BINDING); protocolMarshaller.marshall(serviceError.getType(), TYPE_BINDING); protocolMarshaller.marshall(serviceError.getMessage(), MESSAGE_BINDING); protocolMarshaller.marshall(serviceError.getCreatedAt(), CREATEDAT_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }