mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-02-04 08:13:07 +00:00
Implemented response status converter
This commit is contained in:
@@ -1,25 +1,20 @@
|
|||||||
package com.cappielloantonio.play.subsonic.models;
|
package com.cappielloantonio.play.subsonic.models;
|
||||||
|
|
||||||
public enum ResponseStatus {
|
import com.tickaroo.tikxml.annotation.Attribute;
|
||||||
OK("ok"),
|
import com.tickaroo.tikxml.annotation.Xml;
|
||||||
FAILED("failed");
|
|
||||||
|
|
||||||
private final String value;
|
@Xml
|
||||||
|
public class ResponseStatus {
|
||||||
|
public static String OK = "ok";
|
||||||
|
public static String FAILED = "failed";
|
||||||
|
|
||||||
ResponseStatus(String v) {
|
private String value;
|
||||||
value = v;
|
|
||||||
|
public ResponseStatus(@Attribute String value) {
|
||||||
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String value() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResponseStatus fromValue(String v) {
|
|
||||||
for (ResponseStatus c : ResponseStatus.values()) {
|
|
||||||
if (c.value.equals(v)) {
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException(v);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.cappielloantonio.play.subsonic.utils.converter;
|
||||||
|
|
||||||
|
import com.cappielloantonio.play.subsonic.models.ResponseStatus;
|
||||||
|
import com.tickaroo.tikxml.TypeConverter;
|
||||||
|
|
||||||
|
public class ResponseStatusConverter implements TypeConverter<ResponseStatus> {
|
||||||
|
@Override
|
||||||
|
public ResponseStatus read(String value) throws Exception {
|
||||||
|
return new ResponseStatus(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String write(ResponseStatus value) throws Exception {
|
||||||
|
return value.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user