All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.arangodb.velocypack.internal.VPackSerializers Maven / Gradle / Ivy

There is a newer version: 7.15.0
Show newest version
/*
 * DISCLAIMER
 *
 * Copyright 2016 ArangoDB GmbH, Cologne, Germany
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Copyright holder is ArangoDB GmbH, Cologne, Germany
 */

package com.arangodb.velocypack.internal;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.Date;

import com.arangodb.velocypack.VPackBuilder;
import com.arangodb.velocypack.VPackSerializationContext;
import com.arangodb.velocypack.VPackSerializer;
import com.arangodb.velocypack.VPackSlice;
import com.arangodb.velocypack.exception.VPackException;

/**
 * @author Mark - mark at arangodb.com
 *
 */
public class VPackSerializers {

	private VPackSerializers() {
		super();
	}

	public static VPackSerializer STRING = new VPackSerializer() {
		@Override
		public void serialize(
			final VPackBuilder builder,
			final String attribute,
			final String value,
			final VPackSerializationContext context) throws VPackException {
			builder.add(attribute, value);
		}
	};
	public static VPackSerializer BOOLEAN = new VPackSerializer() {
		@Override
		public void serialize(
			final VPackBuilder builder,
			final String attribute,
			final Boolean value,
			final VPackSerializationContext context) throws VPackException {
			builder.add(attribute, value);
		}
	};
	public static VPackSerializer INTEGER = new VPackSerializer() {
		@Override
		public void serialize(
			final VPackBuilder builder,
			final String attribute,
			final Integer value,
			final VPackSerializationContext context) throws VPackException {
			builder.add(attribute, value);
		}
	};
	public static VPackSerializer LONG = new VPackSerializer() {
		@Override
		public void serialize(
			final VPackBuilder builder,
			final String attribute,
			final Long value,
			final VPackSerializationContext context) throws VPackException {
			builder.add(attribute, value);
		}
	};
	public static VPackSerializer SHORT = new VPackSerializer() {
		@Override
		public void serialize(
			final VPackBuilder builder,
			final String attribute,
			final Short value,
			final VPackSerializationContext context) throws VPackException {
			builder.add(attribute, value);
		}
	};
	public static VPackSerializer DOUBLE = new VPackSerializer() {
		@Override
		public void serialize(
			final VPackBuilder builder,
			final String attribute,
			final Double value,
			final VPackSerializationContext context) throws VPackException {
			builder.add(attribute, value);
		}
	};
	public static VPackSerializer FLOAT = new VPackSerializer() {
		@Override
		public void serialize(
			final VPackBuilder builder,
			final String attribute,
			final Float value,
			final VPackSerializationContext context) throws VPackException {
			builder.add(attribute, value);
		}
	};
	public static VPackSerializer BIG_INTEGER = new VPackSerializer() {
		@Override
		public void serialize(
			final VPackBuilder builder,
			final String attribute,
			final BigInteger value,
			final VPackSerializationContext context) throws VPackException {
			builder.add(attribute, value);
		}
	};
	public static VPackSerializer BIG_DECIMAL = new VPackSerializer() {
		@Override
		public void serialize(
			final VPackBuilder builder,
			final String attribute,
			final BigDecimal value,
			final VPackSerializationContext context) throws VPackException {
			builder.add(attribute, value);
		}
	};
	public static VPackSerializer NUMBER = new VPackSerializer() {
		@Override
		public void serialize(
			final VPackBuilder builder,
			final String attribute,
			final Number value,
			final VPackSerializationContext context) throws VPackException {
			builder.add(attribute, Double.class.cast(value));
		}
	};
	public static VPackSerializer CHARACTER = new VPackSerializer() {
		@Override
		public void serialize(
			final VPackBuilder builder,
			final String attribute,
			final Character value,
			final VPackSerializationContext context) throws VPackException {
			builder.add(attribute, value);
		}
	};
	public static VPackSerializer DATE = new VPackSerializer() {
		@Override
		public void serialize(
			final VPackBuilder builder,
			final String attribute,
			final Date value,
			final VPackSerializationContext context) throws VPackException {
			builder.add(attribute, value);
		}
	};
	public static VPackSerializer SQL_DATE = new VPackSerializer() {
		@Override
		public void serialize(
			final VPackBuilder builder,
			final String attribute,
			final java.sql.Date value,
			final VPackSerializationContext context) throws VPackException {
			builder.add(attribute, value);
		}
	};
	public static VPackSerializer SQL_TIMESTAMP = new VPackSerializer() {
		@Override
		public void serialize(
			final VPackBuilder builder,
			final String attribute,
			final Timestamp value,
			final VPackSerializationContext context) throws VPackException {
			builder.add(attribute, value);
		}
	};
	public static VPackSerializer VPACK = new VPackSerializer() {
		@Override
		public void serialize(
			final VPackBuilder builder,
			final String attribute,
			final VPackSlice value,
			final VPackSerializationContext context) throws VPackException {
			builder.add(attribute, value);
		}
	};
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy