Association.java

/**
* Copyright 2010,2021 Nikolas S Boyd.
Permission is granted to copy this work provided this copyright statement is retained in all copies.

*/
package Hoot.Magnitudes;

import Hoot.Runtime.Functions.*;
import Hoot.Runtime.Faces.*;
import Hoot.Runtime.Values.*;
import Hoot.Runtime.Blocks.*;
import Smalltalk.Core.*;
import Smalltalk.Blocks.*;
import Smalltalk.Magnitudes.*;
import Hoot.Behaviors.*;
import Hoot.Behaviors.Nil;
import Hoot.Behaviors.Object;
import Hoot.Behaviors.True;
import Hoot.Behaviors.False;
import Hoot.Behaviors.Boolean;
import Hoot.Collections.*;
import Hoot.Collections.String;
import Smalltalk.Core.Subject;
import Smalltalk.Core.Posit;
import Smalltalk.Magnitudes.Scalar;
import Smalltalk.Magnitudes.Associated;

public class Association extends Magnitude implements Associated
{

  public static Metaclass type() { return (Metaclass)Metaclass.$class; }
  @Override public Metaclass $class() { return (Metaclass)Metaclass.$class; }
  public static class Metaclass extends Magnitude.Metaclass implements Associated.Metatype
  {
    static final Association.Metaclass $class = new Association.Metaclass();
    public Metaclass() {
      this(Association.Metaclass.class);
    }

    public Metaclass(java.lang.Class aClass) {
      super(aClass);
    }

    @Override public java.lang.Class outerClass() { return Association.class; }

  }


    protected Object key = Nil.literal();
    public Object key() { return this.key; }
    public Object getKey() { return (Object)this.key; }

    public Association key(Object value) { this.key = value; return this; }
    public void setKey(Object value) { this.key = (Object)value; }

  ;
    protected Object value = Nil.literal();
    public Object value() { return this.value; }
    public Object getValue() { return (Object)this.value; }

    public Association value(Object value) { this.value = value; return this; }
    public void setValue(Object value) { this.value = (Object)value; }

  ;

  /**
   * @return 
   */
  public   Association key(final Subject aKey)
  {
    java.lang.String exitID = "Association>>key";
    Frame f0 = new Frame(exitID);
     key = ((Object)aKey);
    return (Association)this;
  }

  /**
   * @return 
   */
  public   Association value(final Subject aValue)
  {
    java.lang.String exitID = "Association>>value";
    Frame f0 = new Frame(exitID);
     value = ((Object)aValue);
    return (Association)this;
  }

  /**
   * @return 
   */
  public   Association key_value(final Object aKey, final Object aValue)
  {
    java.lang.String exitID = "Association>>key_value";
    Frame f0 = new Frame(exitID);
     key = aKey;

     value = aValue;
    return (Association)this;
  }

  /**
   * 
   */
  protected    Association(final Object aKey, final Object aValue)
  {
    java.lang.String exitID = "Association>>Association";
    Frame f0 = new Frame(exitID);
     key = aKey;

     value = aValue;
  }

  /**
   * @return 
   */
  public static   Association withKey_withValue(final Subject aKey, final Subject aValue)
  {
    java.lang.String exitID = "Association>>$withKey_withValue";
    Frame f0 = new Frame(exitID);
    return (Association)new Association(((Object)aKey), ((Object)aValue));
  }

  /**
   * @return 
   */
  @Override public   int hashCode()
  {
    java.lang.String exitID = "Association>>hashCode";
    Frame f0 = new Frame(exitID);
    return (int)key.hashCode();
  }

  /**
   * @return 
   */
  @Override public   Boolean equals(final Magnitude value)
  {
    java.lang.String exitID = "Association>>equals";
    Frame f0 = new Frame(exitID);
    return (Boolean)Association.type().accepts(value).and(Predicate.with(f2 -> {
      return (this.equals(((Association)value)));
    }, ""));
  }

  /**
   * @return 
   */
  @Override public   Boolean lessThan(final Scalar value)
  {
    java.lang.String exitID = "Association>>lessThan";
    Frame f0 = new Frame(exitID);
    return (Boolean)Association.type().accepts(value).and(Predicate.with(f2 -> {
      return (this.lessThan(((Association)value)));
    }, ""));
  }

  /**
   * @return 
   */
  public   Boolean equals(final Association assoc)
  {
    java.lang.String exitID = "Association>>equals";
    Frame f0 = new Frame(exitID);
    return (Boolean)Association.type().accepts(assoc).and(Predicate.with(f2 -> {
      return (this.key().equals(assoc.key())).and(Predicate.with(f3 -> {
      return (this.value().equals(assoc.value()));
    }, ""));
    }, ""));
  }

  /**
   * @return 
   */
  public   Boolean lessThan(final Association assoc)
  {
    java.lang.String exitID = "Association>>lessThan";
    Frame f0 = new Frame(exitID);
    return (Boolean)Association.type().accepts(assoc).and(Predicate.with(f2 -> {
      return (this.key().lessThan(assoc.key()));
    }, ""));
  }

  /**
   * @return 
   */
  @Override public   Association min(final Scalar assoc)
  {
    java.lang.String exitID = "Association>>min";
    Frame f0 = new Frame(exitID);
    return (Association)this.min(((Association)assoc));
  }

  /**
   * @return 
   */
  @Override public   Association max(final Scalar assoc)
  {
    java.lang.String exitID = "Association>>max";
    Frame f0 = new Frame(exitID);
    return (Association)this.max(((Association)assoc));
  }

  /**
   * @return 
   */
  public   Association min(final Association assoc)
  {
    java.lang.String exitID = "Association>>min";
    Frame f0 = new Frame(exitID);
    if ((assoc == null)) {
      return this;
    };
    if (this.lessThan(assoc).primitiveBoolean()) {
      return this;
    };
    return (Association)assoc;
  }

  /**
   * @return 
   */
  public   Association max(final Association assoc)
  {
    java.lang.String exitID = "Association>>max";
    Frame f0 = new Frame(exitID);
    if ((assoc == null)) {
      return this;
    };
    if (this.moreThan(assoc).primitiveBoolean()) {
      return this;
    };
    return (Association)assoc;
  }

  /**
   * @return 
   */
  @Override public   java.lang.String toString()
  {
    java.lang.String exitID = "Association>>toString";
    Frame f0 = new Frame(exitID);
    return (java.lang.String)this.printTerm().primitiveString();
  }

  /**
   * @return 
   */
  @Override public   String printString()
  {
    java.lang.String exitID = "Association>>printString";
    Frame f0 = new Frame(exitID);
    return (String)key.printString().append(String.from(" >> ")).append(value.printString());
  }
}