001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019 020package org.apache.isis.core.progmodel.facets.value.date; 021 022import java.util.Date; 023 024import org.apache.isis.applib.adapters.EncoderDecoder; 025import org.apache.isis.applib.adapters.Parser; 026import org.apache.isis.core.commons.config.IsisConfiguration; 027import org.apache.isis.core.metamodel.facetapi.FacetHolder; 028import org.apache.isis.core.progmodel.facets.object.value.ValueSemanticsProviderContext; 029 030public class DateValueSemanticsProvider extends DateValueSemanticsProviderAbstract<org.apache.isis.applib.value.Date> { 031 032 // no default 033 private static final org.apache.isis.applib.value.Date DEFAULT_VALUE = null; 034 035 036 /** 037 * Required because implementation of {@link Parser} and 038 * {@link EncoderDecoder}. 039 */ 040 public DateValueSemanticsProvider() { 041 this(null, null, null); 042 } 043 044 public DateValueSemanticsProvider(final FacetHolder holder, final IsisConfiguration configuration, final ValueSemanticsProviderContext context) { 045 super(holder, org.apache.isis.applib.value.Date.class, Immutability.NOT_IMMUTABLE, EqualByContent.NOT_HONOURED, DEFAULT_VALUE, configuration, context); 046 } 047 048 @Override 049 protected org.apache.isis.applib.value.Date add(final org.apache.isis.applib.value.Date original, final int years, final int months, final int days, final int hours, final int minutes) { 050 final org.apache.isis.applib.value.Date date = original; 051 return date.add(years, months, days); 052 } 053 054 @Override 055 protected org.apache.isis.applib.value.Date now() { 056 return new org.apache.isis.applib.value.Date(); 057 } 058 059 @Override 060 protected Date dateValue(final Object value) { 061 return ((org.apache.isis.applib.value.Date) value).dateValue(); 062 } 063 064 @Override 065 protected org.apache.isis.applib.value.Date setDate(final Date date) { 066 return new org.apache.isis.applib.value.Date(date); 067 } 068}