-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Java implementation for real-time notifications
- Loading branch information
1 parent
41c5ecd
commit 321c598
Showing
11 changed files
with
675 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
java-client-model/src/main/java/com/cumulocity/model/NotificationConverters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package com.cumulocity.model; | ||
|
||
import org.svenson.converter.TypeConverter; | ||
|
||
import com.cumulocity.model.idtype.GId; | ||
import com.cumulocity.rest.representation.alarm.AlarmRepresentation; | ||
import com.cumulocity.rest.representation.event.EventRepresentation; | ||
import com.cumulocity.rest.representation.inventory.ManagedObjectRepresentation; | ||
import com.cumulocity.rest.representation.measurement.MeasurementRepresentation; | ||
import com.cumulocity.rest.representation.operation.OperationRepresentation; | ||
|
||
public class NotificationConverters { | ||
|
||
public static class DeletedManagedObjectConverter implements TypeConverter { | ||
|
||
@Override | ||
public Object fromJSON(Object o) { | ||
if (o instanceof String) { | ||
ManagedObjectRepresentation wrapper = new ManagedObjectRepresentation(); | ||
wrapper.set(new GId((String)o)); | ||
o = wrapper; | ||
} | ||
return o; | ||
} | ||
|
||
@Override | ||
public Object toJSON(Object o) { // not needed at all | ||
return o; | ||
} | ||
|
||
} | ||
|
||
public static class DeletedMeasurementConverter implements TypeConverter { | ||
|
||
@Override | ||
public Object fromJSON(Object o) { | ||
if (o instanceof String) { | ||
MeasurementRepresentation wrapper = new MeasurementRepresentation(); | ||
wrapper.set(new GId((String)o)); | ||
o = wrapper; | ||
} | ||
return o; | ||
} | ||
|
||
@Override | ||
public Object toJSON(Object o) { // not needed at all | ||
return o; | ||
} | ||
|
||
} | ||
|
||
public static class DeletedEventConverter implements TypeConverter { | ||
|
||
@Override | ||
public Object fromJSON(Object o) { | ||
if (o instanceof String) { | ||
EventRepresentation wrapper = new EventRepresentation(); | ||
wrapper.set(new GId((String)o)); | ||
o = wrapper; | ||
} | ||
return o; | ||
} | ||
|
||
@Override | ||
public Object toJSON(Object o) { // not needed at all | ||
return o; | ||
} | ||
|
||
} | ||
|
||
public static class DeletedAlarmConverter implements TypeConverter { | ||
|
||
@Override | ||
public Object fromJSON(Object o) { | ||
if (o instanceof String) { | ||
AlarmRepresentation wrapper = new AlarmRepresentation(); | ||
wrapper.set(new GId((String)o)); | ||
o = wrapper; | ||
} | ||
return o; | ||
} | ||
|
||
@Override | ||
public Object toJSON(Object o) { // not needed at all | ||
return o; | ||
} | ||
|
||
} | ||
|
||
public static class DeletedOperationConverter implements TypeConverter { | ||
|
||
@Override | ||
public Object fromJSON(Object o) { | ||
if (o instanceof String) { | ||
OperationRepresentation wrapper = new OperationRepresentation(); | ||
wrapper.set(new GId((String)o)); | ||
o = wrapper; | ||
} | ||
return o; | ||
} | ||
|
||
@Override | ||
public Object toJSON(Object o) { // not needed at all | ||
return o; | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.