View Javadoc
1   /*
2    * Copyright 2001-2005 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.logging.log4j.catalog.api.plugins;
17  
18  import java.io.IOException;
19  
20  import com.fasterxml.jackson.core.JsonGenerator;
21  import com.fasterxml.jackson.core.JsonParser;
22  import com.fasterxml.jackson.core.JsonProcessingException;
23  import com.fasterxml.jackson.databind.DeserializationContext;
24  import com.fasterxml.jackson.databind.JsonNode;
25  import com.fasterxml.jackson.databind.SerializerProvider;
26  import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
27  import com.fasterxml.jackson.databind.ser.std.StdSerializer;
28  import org.apache.logging.log4j.catalog.api.ConstraintType;
29  import org.apache.logging.log4j.catalog.api.exception.NameNotFoundException;
30  
31  /**
32   *
33   */
34  public class ConstraintTypeSerializer extends StdSerializer<ConstraintType> {
35  
36      public ConstraintTypeSerializer() {
37          this(null);
38      }
39  
40      public ConstraintTypeSerializer(Class<ConstraintType> vc) {
41          super(vc);
42      }
43  
44      @Override
45      public void serialize(ConstraintType constraintType, JsonGenerator jsonGenerator,
46                            SerializerProvider serializerProvider) throws IOException {
47          jsonGenerator.writeStartObject();
48          jsonGenerator.writeStringField("name", constraintType.getName());
49          jsonGenerator.writeEndObject();
50      }
51  }