Package org.hibernate.search.bridge.builtin

Source Code of org.hibernate.search.bridge.builtin.DateResolutionUtil

/*
* Hibernate Search, full-text search for your domain model
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.search.bridge.builtin;

import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.DateTools.Resolution;
import org.hibernate.search.exception.AssertionFailure;

public class DateResolutionUtil {

  private DateResolutionUtil() {
  }

  public static Resolution getLuceneResolution(org.hibernate.search.annotations.Resolution hibResolution) {
    Resolution resolution = null;
    switch (hibResolution) {
      case YEAR:
        resolution = DateTools.Resolution.YEAR;
        break;
      case MONTH:
        resolution = DateTools.Resolution.MONTH;
        break;
      case DAY:
        resolution = DateTools.Resolution.DAY;
        break;
      case HOUR:
        resolution = DateTools.Resolution.HOUR;
        break;
      case MINUTE:
        resolution = DateTools.Resolution.MINUTE;
        break;
      case SECOND:
        resolution = DateTools.Resolution.SECOND;
        break;
      case MILLISECOND:
        resolution = DateTools.Resolution.MILLISECOND;
        break;
      default:
        throw new AssertionFailure( "Unknown Resolution: " + hibResolution );
    }
    return resolution;
  }
}
TOP

Related Classes of org.hibernate.search.bridge.builtin.DateResolutionUtil

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.