Class BuckStarlarkStructObject

  • All Implemented Interfaces:
    com.google.devtools.build.lib.skylarkinterface.SkylarkPrintable, com.google.devtools.build.lib.skylarkinterface.SkylarkValue, com.google.devtools.build.lib.syntax.ClassObject
    Direct Known Subclasses:
    BuiltInProviderInfo

    public abstract class BuckStarlarkStructObject
    extends Object
    implements com.google.devtools.build.lib.syntax.ClassObject, com.google.devtools.build.lib.skylarkinterface.SkylarkValue
    Marks a Java object as accessible by Skylark as a struct-like object called ClassObject. This also marks it as a SkylarkValue.

    A struct like object is an object containing fields accessible via the dot syntax, like obj.field.

    We currently do not support method calls.

    • Constructor Detail

      • BuckStarlarkStructObject

        public BuckStarlarkStructObject()
    • Method Detail

      • getValue

        @Nullable
        public Object getValue​(String name)
                        throws com.google.devtools.build.lib.syntax.EvalException
        Specified by:
        getValue in interface com.google.devtools.build.lib.syntax.ClassObject
        Throws:
        com.google.devtools.build.lib.syntax.EvalException
      • getMethods

        protected com.google.common.collect.ImmutableMap<String,​Method> getMethods()
      • getDeclaredClass

        protected abstract Class<?> getDeclaredClass()
        Returns:
        the class for which all declared methods on it are considered skylark accessible.
      • getFieldNames

        public com.google.common.collect.ImmutableCollection<String> getFieldNames()
        Specified by:
        getFieldNames in interface com.google.devtools.build.lib.syntax.ClassObject
      • getErrorMessageForUnknownField

        @Nullable
        public String getErrorMessageForUnknownField​(String field)
        Specified by:
        getErrorMessageForUnknownField in interface com.google.devtools.build.lib.syntax.ClassObject
      • repr

        public void repr​(com.google.devtools.build.lib.skylarkinterface.SkylarkPrinter printer)
        Specified by:
        repr in interface com.google.devtools.build.lib.skylarkinterface.SkylarkPrintable