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

com.spun.util.database.automaticsetter.AddDateVariableSetter Maven / Gradle / Ivy

There is a newer version: 24.9.0
Show newest version
package com.spun.util.database.automaticsetter;

import com.spun.util.database.AutomaticVariableSetter;
import com.spun.util.database.DatabaseObject;

import java.sql.Statement;
import java.sql.Timestamp;

public class AddDateVariableSetter implements AutomaticVariableSetter
{
  public static final AddDateVariableSetter INSTANCE = new AddDateVariableSetter();
  private AddDateVariableSetter()
  {
  }
  public void setFor(DatabaseObject forObject, int atStage, Statement stmt)
  {
    AddDateAware addDate = (AddDateAware) forObject;
    if (atStage == AutomaticVariableSetter.INSERT && addDate.getAddDate() == null)
    {
      if (forObject instanceof ChangeDateAware && ((ChangeDateAware) forObject).getChangeDate() != null)
      {
        ((AddDateAware) forObject).setAddDate(((ChangeDateAware) forObject).getChangeDate());
      }
      else
      {
        ((AddDateAware) forObject).setAddDate(new Timestamp(System.currentTimeMillis()));
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy