alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (ConstructedType.java)

This example Scala source code file (ConstructedType.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

constructedtype, constructedtype, string, string, type, type, util

The Scala ConstructedType.java source code

package ch.epfl.lamp.compiler.msil;

import java.util.Arrays;

/* The only reason for ConstructedType to extend Type is complying with existing code
  (e.g., caseFieldBuilder in ILPrinterVisitor) expecting a Type. 
 */
public class ConstructedType extends Type {

    public final Type instantiatedType;
    public final Type[] typeArgs;

    public ConstructedType(Type instantiatedType, Type[] typeArgs) {
        super(instantiatedType.Module, instantiatedType.Attributes, "", null, null, null, instantiatedType.auxAttr /*AuxAttr.None*/ , null);
        this.instantiatedType = instantiatedType;
        this.typeArgs = typeArgs;
    }

    public String toString() {
        String res = instantiatedType.toString()  + "[";
        for (int i = 0; i < typeArgs.length; i++) {
            res = res + typeArgs[i].toString();
            if(i + 1 < typeArgs.length) {
                res = res + ", ";
            }
        }
        return res + "]";
    }


    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ConstructedType that = (ConstructedType) o;

        if (!instantiatedType.equals(that.instantiatedType)) return false;
        if (!Arrays.equals(typeArgs, that.typeArgs)) return false;

        return true;
    }

    public int hashCode() {
        int result = instantiatedType.hashCode();
        result = 31 * result + Arrays.hashCode(typeArgs);
        return result;
    }
}

Other Scala examples (source code examples)

Here is a short list of links related to this Scala ConstructedType.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.