Skip to content

Instantly share code, notes, and snippets.

@jonasurbano jonasurbano/
Last active Dec 28, 2015

What would you like to do?
package org.pfc.domain;
import javax.persistence.Column;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.pfc.utils.JsonMap;
public class Servicio {
private static final String CLAVE_VISITAS = "visitas";
// Otras propiedades
private String misc;
// Otros métodos
* Obtiene {@code clave} del misc
* convirtiendo a Map el String
private String getMisc(String clave) {
return JsonMap.toMap(misc).get(clave);
* Añade o actualiza {@code "clave"} en el JSON
* convirtiendo a Map la propiedad misc
private void setMisc(String clave,String valor) {
misc = JsonMap.toJson(clave, valor, misc);
public int getVisitas() {
String visitas = getMisc(CLAVE_VISITAS);
if (visitas == null) return 0;
try {
return Integer.parseInt(visitas);
} catch (Exception e) {
return 0;
public void incrementarVisitas() {
int visitas = getVisitas();
if (visitas == 0) setMisc(CLAVE_VISITAS, Integer.toString(1));
else setMisc(CLAVE_VISITAS,Integer.toString(++visitas));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.