// Path: src/util/src/main/java/org/lilycms/util/ArgumentValidator.java
// public class ArgumentValidator {
//     public static void notNull(Object object, String argName) {
//         if (object == null)
//             throw new IllegalArgumentException("Null argument: " + argName);
//     }
// }


import org.apache.hadoop.hbase.util.Bytes;
import org.codehaus.jackson.node.ObjectNode;
import org.lilycms.util.ArgumentValidator;
import java.util.*;
/*
 * Copyright 2010 Outerthought bvba
 *
 * 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.
 */
package org.lilycms.hbaseindex;



/**
 * Index field for datetimes, dates, times.
 *
 * <p>The instant is stored in the index as a long, or in case there is only a time
 * component, as an integer.
 *
 * <p>This class accepts java.util.Date as date/time representation. It is up to the
 * user to make sure any timezone corrections have happened already.
 */
public class DateTimeIndexFieldDefinition  extends IndexFieldDefinition {
    public enum Precision {DATETIME, DATETIME_NOMILLIS, DATE, TIME, TIME_NOMILLIS}
    private Precision precision = Precision.DATETIME_NOMILLIS;

    public DateTimeIndexFieldDefinition(String name) {
        super(name, IndexValueType.DATETIME);
    }

    public DateTimeIndexFieldDefinition(String name, ObjectNode jsonObject) {
        super(name, IndexValueType.DATETIME);

        if (jsonObject.get("precision") != null)
            this.precision = Precision.valueOf(jsonObject.get("precision").getTextValue());
    }

    public Precision getPrecision() {
        return precision;
    }

    public void setPrecision(Precision precision) {
// Path: src/util/src/main/java/org/lilycms/util/ArgumentValidator.java
// public class ArgumentValidator {
//     public static void notNull(Object object, String argName) {
//         if (object == null)
//             throw new IllegalArgumentException("Null argument: " + argName);
//     }
// }


// Path: src/hbaseindex/src/main/java/org/lilycms/hbaseindex/DateTimeIndexFieldDefinition.java
import org.apache.hadoop.hbase.util.Bytes;
import org.codehaus.jackson.node.ObjectNode;
import org.lilycms.util.ArgumentValidator;
import java.util.*;

/*
 * Copyright 2010 Outerthought bvba
 *
 * 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.
 */
package org.lilycms.hbaseindex;



/**
 * Index field for datetimes, dates, times.
 *
 * <p>The instant is stored in the index as a long, or in case there is only a time
 * component, as an integer.
 *
 * <p>This class accepts java.util.Date as date/time representation. It is up to the
 * user to make sure any timezone corrections have happened already.
 */
public class DateTimeIndexFieldDefinition  extends IndexFieldDefinition {
    public enum Precision {DATETIME, DATETIME_NOMILLIS, DATE, TIME, TIME_NOMILLIS}
    private Precision precision = Precision.DATETIME_NOMILLIS;

    public DateTimeIndexFieldDefinition(String name) {
        super(name, IndexValueType.DATETIME);
    }

    public DateTimeIndexFieldDefinition(String name, ObjectNode jsonObject) {
        super(name, IndexValueType.DATETIME);

        if (jsonObject.get("precision") != null)
            this.precision = Precision.valueOf(jsonObject.get("precision").getTextValue());
    }

    public Precision getPrecision() {
        return precision;
    }

    public void setPrecision(Precision precision) {
        ArgumentValidator.notNull(precision, "precision");