Skip to content

Commit

Permalink
add missed file
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroVega committed Feb 7, 2024
1 parent 386d643 commit 24b25d8
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.telefonica.iot.cygnus.management;

import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;

import java.io.IOException;
import java.util.regex.Pattern;

public class PatternTypeAdapter extends TypeAdapter<Pattern> {

@Override
public void write(JsonWriter out, Pattern pattern) throws IOException {
if (pattern == null) {
out.nullValue();
return;
}
out.value(pattern.pattern());
}

@Override
public Pattern read(JsonReader in) throws IOException {
String patternString = in.nextString();
return Pattern.compile(patternString);
}
}

0 comments on commit 24b25d8

Please sign in to comment.