View Javadoc
1   /*
2    * ObjectLab, http://www.objectlab.co.uk/open is sponsoring the ObjectLab Kit.
3    *
4    * Based in London, we are world leaders in the design and development
5    * of bespoke applications for the securities financing markets.
6    *
7    * <a href="http://www.objectlab.co.uk/open">Click here to learn more</a>
8    *           ___  _     _           _   _          _
9    *          / _ \| |__ (_) ___  ___| |_| |    __ _| |__
10   *         | | | | '_ \| |/ _ \/ __| __| |   / _` | '_ \
11   *         | |_| | |_) | |  __/ (__| |_| |__| (_| | |_) |
12   *          \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
13   *                   |__/
14   *
15   *                     www.ObjectLab.co.uk
16   *
17   * $Id$
18   *
19   * Copyright 2006 the original author or authors.
20   *
21   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
22   * use this file except in compliance with the License. You may obtain a copy of
23   * the License at
24   *
25   * http://www.apache.org/licenses/LICENSE-2.0
26   *
27   * Unless required by applicable law or agreed to in writing, software
28   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
29   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
30   * License for the specific language governing permissions and limitations under
31   * the License.
32   */
33  package net.objectlab.kit.datecalc.joda;
34  
35  import net.objectlab.kit.datecalc.common.BaseCalculator;
36  import net.objectlab.kit.datecalc.common.HolidayHandlerType;
37  
38  import org.joda.time.LocalDate;
39  
40  /**
41   * A backward handler will move the date backward if it falls on a non working
42   * day.
43   *
44   * @author Benoit Xhenseval
45   *
46   */
47  public class LocalDateBackwardHandler extends LocalDateForwardHandler {
48  
49      /**
50       * If the current date of the give calculator is a non-working day, it will
51       * be moved according to the algorithm implemented.
52       *
53       * @param calculator
54       *            the calculator
55       * @return the date which may have moved.
56       */
57      @Override
58      public LocalDate moveCurrentDate(final BaseCalculator<LocalDate> calculator) {
59          return adjustDate(calculator.getCurrentBusinessDate(), -1, calculator);
60      }
61  
62      // -----------------------------------------------------------------------
63      //
64      // ObjectLab, world leaders in the design and development of bespoke
65      // applications for the securities financing markets.
66      // www.ObjectLab.co.uk
67      //
68      // -----------------------------------------------------------------------
69  
70      /**
71       * Give the type name for this algorithm.
72       *
73       * @return algorithm name.
74       */
75      @Override
76      public String getType() {
77          return HolidayHandlerType.BACKWARD;
78      }
79  }
80  
81  /*
82   * ObjectLab, http://www.objectlab.co.uk/open is sponsoring the ObjectLab Kit.
83   *
84   * Based in London, we are world leaders in the design and development
85   * of bespoke applications for the securities financing markets.
86   *
87   * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a>
88   *           ___  _     _           _   _          _
89   *          / _ \| |__ (_) ___  ___| |_| |    __ _| |__
90   *         | | | | '_ \| |/ _ \/ __| __| |   / _` | '_ \
91   *         | |_| | |_) | |  __/ (__| |_| |__| (_| | |_) |
92   *          \___/|_.__// |\___|\___|\__|_____\__,_|_.__/
93   *                   |__/
94   *
95   *                     www.ObjectLab.co.uk
96   */