Skip to content

Commit

Permalink
simpler POJOs
Browse files Browse the repository at this point in the history
  • Loading branch information
shoeffner committed Oct 15, 2016
1 parent aed1bc6 commit cac2c3f
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.base.Preconditions;
import com.intuit.wasabi.exceptions.AnalyticsException;
import com.intuit.wasabi.experimentobjects.Context;
import io.swagger.annotations.ApiModelProperty;
Expand Down Expand Up @@ -68,7 +67,10 @@ public Date getTimestamp() {
}

public void setTimestamp(Date value) {
timestamp = new Date(Preconditions.checkNotNull(value, "Event timestamp must not be null.").getTime());
if (Objects.isNull(value)) {
throw new IllegalArgumentException("Event timestamp must not be null.");
}
timestamp = new Date(value.getTime());
}

public Type getType() {
Expand All @@ -86,7 +88,6 @@ public void setName(Event.Name value) {
name = value;
switch (name.toString()) {
case IMPRESSION:
case "":
type = Type.IMPRESSION;
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*******************************************************************************/
package com.intuit.wasabi.assignmentobjects;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -48,22 +47,38 @@
*/
public final class AssignmentEnvelopePayload implements EnvelopePayload {
private static final Logger LOG = LoggerFactory.getLogger(AssignmentEnvelopePayload.class);
private final MessageType messageType = MessageType.ASSIGNMENT;
private final String version = "3.0";
private final User.ID userID;
private final Context context;
private final boolean createAssignment;
private final boolean putAssignment;
private final boolean ignoreSamplingPercent;
private final SegmentationProfile segmentationProfile;
private final Assignment.Status assignmentStatus;
private final Bucket.Label bucketLabel;
private final Page.Name pageName;
private final Application.Name applicationName;
private final Experiment.Label experimentLabel;
private final Experiment.ID experimentID;
private final Date assignmentTimestamp;
private final UUID timeUUID = UUIDGen.getTimeUUID();
@JsonProperty("messageType")
private MessageType messageType = MessageType.ASSIGNMENT;
@JsonProperty("version")
private String version = "3.0";
@JsonProperty("userID")
private User.ID userID;
@JsonProperty("context")
private Context context;
@JsonProperty("createAssignment")
private boolean createAssignment;
@JsonProperty("putAssignment")
private boolean putAssignment;
@JsonProperty("ignoreSamplingPercent")
private boolean ignoreSamplingPercent;
@JsonProperty("segmentationProfile")
private SegmentationProfile segmentationProfile;
@JsonProperty("assignmentStatus")
private Assignment.Status assignmentStatus;
@JsonProperty("bucketLabel")
private Bucket.Label bucketLabel;
@JsonProperty("pageName")
private Page.Name pageName;
@JsonProperty("applicationName")
private Application.Name applicationName;
@JsonProperty("experimentLabel")
private Experiment.Label experimentLabel;
@JsonProperty("experimentID")
private Experiment.ID experimentID;
@JsonProperty("assignmentTimestamp")
private Date assignmentTimestamp;
@JsonProperty("timeUUID")
private UUID timeUUID = UUIDGen.getTimeUUID();

/**
* @param userID the user ID
Expand All @@ -80,21 +95,20 @@ public final class AssignmentEnvelopePayload implements EnvelopePayload {
* @param experimentID the experiment ID
* @param assignmentTimestamp the assignment's date
*/
@JsonCreator
public AssignmentEnvelopePayload(
@JsonProperty("userID") ID userID,
@JsonProperty("context") Context context,
@JsonProperty("createAssignment") boolean createAssignment,
@JsonProperty("putAssignment") boolean putAssignment,
@JsonProperty("ignoreSamplingPercent") boolean ignoreSamplingPercent,
@JsonProperty("segmentationProfile") SegmentationProfile segmentationProfile,
@JsonProperty("assignmentStatus") Status assignmentStatus,
@JsonProperty("bucketLabel") Bucket.Label bucketLabel,
@JsonProperty("pageName") Page.Name pageName,
@JsonProperty("applicationName") Name applicationName,
@JsonProperty("experimentLabel") Label experimentLabel,
@JsonProperty("experimentID") Experiment.ID experimentID,
@JsonProperty("assignmentTimestamp") Date assignmentTimestamp) {
ID userID,
Context context,
boolean createAssignment,
boolean putAssignment,
boolean ignoreSamplingPercent,
SegmentationProfile segmentationProfile,
Status assignmentStatus,
Bucket.Label bucketLabel,
Page.Name pageName,
Name applicationName,
Label experimentLabel,
Experiment.ID experimentID,
Date assignmentTimestamp) {
this.userID = userID;
this.context = context;
this.createAssignment = createAssignment;
Expand All @@ -110,116 +124,7 @@ public AssignmentEnvelopePayload(
this.assignmentTimestamp = assignmentTimestamp;
}

/**
* @return the userID
*/
public User.ID getUserID() {
return userID;
}

/**
* @return the context
*/
public Context getContext() {
return context;
}

/**
* @return the createAssignment
*/
public boolean isCreateAssignment() {
return createAssignment;
}

/**
* @return the putAssignment
*/
public boolean isPutAssignment() {
return putAssignment;
}

/**
* @return the ignoreSamplingPercent
*/
public boolean isIgnoreSamplingPercent() {
return ignoreSamplingPercent;
}

/**
* @return the segmentationProfile
*/
public SegmentationProfile getSegmentationProfile() {
return segmentationProfile;
}

/**
* @return the assignmentStatus
*/
public Assignment.Status getAssignmentStatus() {
return assignmentStatus;
}

/**
* @return the bucketLabel
*/
public Bucket.Label getBucketLabel() {
return bucketLabel;
}

/**
* @return the pageName
*/
public Page.Name getPageName() {
return pageName;
}

/**
* @return the applicationName
*/
public Application.Name getApplicationName() {
return applicationName;
}

/**
* @return the experimentLabel
*/
public Experiment.Label getExperimentLabel() {
return experimentLabel;
}

/**
* @return the experimentID
*/
public Experiment.ID getExperimentID() {
return experimentID;
}

/**
* @return the assignmentTimestamp
*/
public Date getAssignmentTimestamp() {
return assignmentTimestamp;
}

/**
* @return the time UUID
*/
public UUID getTimeUUID() {
return timeUUID;
}

/**
* @return the message type
*/
public MessageType getMessageType() {
return messageType;
}

/**
* @return the version
*/
public String getVersion() {
return version;
private AssignmentEnvelopePayload() {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
*******************************************************************************/
package com.intuit.wasabi.eventobjects;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.intuit.wasabi.analyticsobjects.Event;
import com.intuit.wasabi.assignmentobjects.Assignment;
import com.intuit.wasabi.assignmentobjects.AssignmentEnvelopePayload;
import com.intuit.wasabi.experimentobjects.Application;
import com.intuit.wasabi.experimentobjects.Application.Name;
import com.intuit.wasabi.experimentobjects.Experiment;
Expand All @@ -45,12 +43,19 @@
*/
public class EventEnvelopePayload implements EnvelopePayload {
private static final Logger LOG = LoggerFactory.getLogger(EventEnvelopePayload.class);
private final MessageType messageType = MessageType.EVENT;
private final String version = "3.0";
private final UUID timeUUID = UUIDGen.getTimeUUID();
@JsonProperty("messageType")
private MessageType messageType = MessageType.EVENT;
@JsonProperty("version")
private String version = "3.0";
@JsonProperty("timeUUID")
private UUID timeUUID = UUIDGen.getTimeUUID();
@JsonProperty("applicationName")
private Name applicationName;
@JsonProperty("experimentLabel")
private Label experimentLabel;
@JsonProperty("assignment")
private Assignment assignment;
@JsonProperty("event")
private Event event;

/**
Expand All @@ -59,52 +64,17 @@ public class EventEnvelopePayload implements EnvelopePayload {
* @param assignment the assignment {@link Assignment}
* @param event the event {@link Event}
*/
@JsonCreator
public EventEnvelopePayload(@JsonProperty("applicationName") Application.Name applicationName,
@JsonProperty("experimentLabel") Experiment.Label experimentLabel,
@JsonProperty("assignment") Assignment assignment,
@JsonProperty("event") Event event) {
public EventEnvelopePayload(Application.Name applicationName,
Experiment.Label experimentLabel,
Assignment assignment,
Event event) {
this.applicationName = applicationName;
this.experimentLabel = experimentLabel;
this.assignment = assignment;
this.event = event;
}

public Name getApplicationName() {
return applicationName;
}

public Label getExperimentLabel() {
return experimentLabel;
}

public Assignment getAssignment() {
return assignment;
}

public Event getEvent() {
return event;
}

/**
* @return the time UUID
*/
public UUID getTimeUUID() {
return timeUUID;
}

/**
* @return the message type
*/
public MessageType getMessageType() {
return messageType;
}

/**
* @return the version
*/
public String getVersion() {
return version;
private EventEnvelopePayload() {
}

@Override
Expand Down

0 comments on commit cac2c3f

Please sign in to comment.