当前位置: 首页>>代码示例>>Java>>正文


Java MissingPropertyException类代码示例

本文整理汇总了Java中groovy.lang.MissingPropertyException的典型用法代码示例。如果您正苦于以下问题:Java MissingPropertyException类的具体用法?Java MissingPropertyException怎么用?Java MissingPropertyException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MissingPropertyException类属于groovy.lang包,在下文中一共展示了MissingPropertyException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: determineName

import groovy.lang.MissingPropertyException; //导入依赖的package包/类
public String determineName(Object thing) {
    Object name;
    try {
        if (thing instanceof Named) {
            name = ((Named) thing).getName();
        } else if (thing instanceof Map) {
            name = ((Map) thing).get("name");
        } else if (thing instanceof GroovyObject) {
            name = ((GroovyObject) thing).getProperty("name");
        } else {
            name = DynamicObjectUtil.asDynamicObject(thing).getProperty("name");
        }
    } catch (MissingPropertyException e) {
        throw new NoNamingPropertyException(thing);
    }

    if (name == null) {
        throw new NullNamingPropertyException(thing);
    }

    return name.toString();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:DynamicPropertyNamer.java

示例2: setProperty

import groovy.lang.MissingPropertyException; //导入依赖的package包/类
@Override
public void setProperty(final String property, final Object newValue) {
    if (property == null) {
        throw new MissingPropertyException("null", getClass());
    }
    switch (property) {
        case "sha":
        case "url":
        case "author":
        case "committer":
        case "parents":
        case "message":
        case "comment_count":
        case "comments":
        case "additions":
        case "deletions":
        case "total_changes":
        case "files":
        case "statuses":
            throw new ReadOnlyPropertyException(property, getClass());
        default:
            throw new MissingPropertyException(property, getClass());
    }
}
 
开发者ID:aaronjwhiteside,项目名称:pipeline-github,代码行数:25,代码来源:CommitGroovyObject.java

示例3: setProperty

import groovy.lang.MissingPropertyException; //导入依赖的package包/类
@Override
public void setProperty(final String property, final Object newValue) {
    if (property == null) {
        throw new MissingPropertyException("null", getClass());
    }

    switch (property) {
        case "sha":
        case "filename":
        case "status":
        case "patch":
        case "additions":
        case "deletions":
        case "changes":
        case "raw_url":
        case "blob_url":
            throw new ReadOnlyPropertyException(property, getClass());
        default:
            throw new MissingPropertyException(property, getClass());
    }
}
 
开发者ID:aaronjwhiteside,项目名称:pipeline-github,代码行数:22,代码来源:CommitFileGroovyObject.java

示例4: getProperty

import groovy.lang.MissingPropertyException; //导入依赖的package包/类
@Override
public Object getProperty(final String property) {
    if (property == null) {
        throw new MissingPropertyException("null", getClass());
    }
    switch (property) {
        case "id":
            return comment.getId();
        case "url":
            return comment.getUrl();
        case "user":
            return GitHubHelper.userToLogin(comment.getUser());
        case "body":
            return comment.getBody();
        case "created_at":
            return comment.getCreatedAt();
        case "updated_at":
            return comment.getUpdatedAt();

        default:
            throw new MissingPropertyException(property, getClass());
    }
}
 
开发者ID:aaronjwhiteside,项目名称:pipeline-github,代码行数:24,代码来源:IssueCommentGroovyObject.java

示例5: setProperty

import groovy.lang.MissingPropertyException; //导入依赖的package包/类
@Override
public void setProperty(final String property, final Object newValue) {
    if (property == null) {
        throw new MissingPropertyException("null", getClass());
    }
    switch (property) {
        case "id":
        case "url":
        case "user":
        case "created_at":
        case "updated_at":
            throw new ReadOnlyPropertyException(property, getClass());

        case "body":
            setBody(newValue.toString());
            break;

        default:
            throw new MissingPropertyException(property, getClass());
    }
}
 
开发者ID:aaronjwhiteside,项目名称:pipeline-github,代码行数:22,代码来源:IssueCommentGroovyObject.java

示例6: setProperty

import groovy.lang.MissingPropertyException; //导入依赖的package包/类
@Override
public void setProperty(final String property, final Object newValue) {
    if (property == null) {
        throw new MissingPropertyException("null", getClass());
    }

    switch (property) {
        case "id":
        case "url":
        case "status":
        case "context":
        case "description":
        case "target_url":
        case "created_at":
        case "updated_at":
        case "creator":
            throw new ReadOnlyPropertyException(property, getClass());
        default:
            throw new MissingPropertyException(property, getClass());
    }
}
 
开发者ID:aaronjwhiteside,项目名称:pipeline-github,代码行数:22,代码来源:CommitStatusGroovyObject.java

示例7: doGetVariable

import groovy.lang.MissingPropertyException; //导入依赖的package包/类
/**
 * Result {@code null} means that there is no variable. Result other than {@code null} means that there is a variable (that may possibly
 * be {@code null}).
 *
 * @param name the name of the variable.
 * @return a holder for a variable.
 */
protected Mutable<Object> doGetVariable(String name) {
    List<Object> variables =
            scripts.stream().filter(script -> script.getMetaClass().hasProperty(script.getMetaClass().getTheClass(), name) != null)
                    .map(script -> script.getProperty(name)).collect(Collectors.toList());

    if (variables.isEmpty()) {
        try {
            return new MutableObject<>(binding.getProperty(name));
        } catch (MissingPropertyException e) {
            return null; // This means that no variable has been found!
        }
    }

    return new MutableObject<>(variables.get(0));
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:23,代码来源:GroovyKnowledgeBaseInterpreter.java

示例8: danGenerateEntity

import groovy.lang.MissingPropertyException; //导入依赖的package包/类
@TaskAction
public void danGenerateEntity() {
    try {
        String entities = (String) this.getProject().property("entities");
        if (entities != null) {
            for(String entity: Arrays.asList(entities.split(","))) {
                new DanConsole().generateEntity(entity);
            }
        } else {
            throw new MissingPropertyException("");
        }
    } catch (MissingPropertyException e) {
        System.err.println(USAGE);
        throw e;
    }

}
 
开发者ID:rulo7,项目名称:dan-console,代码行数:18,代码来源:DanEntityTask.java

示例9: shouldClearBindingsBetweenEvals

import groovy.lang.MissingPropertyException; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldClearBindingsBetweenEvals() throws Exception {
    final ScriptEngine engine = new GremlinGroovyScriptEngine();
    engine.put("g", g);
    engine.put("marko", convertToVertexId("marko"));
    assertEquals(g.V(convertToVertexId("marko")).next(), engine.eval("g.V(marko).next()"));

    final Bindings bindings = engine.createBindings();
    bindings.put("g", g);
    bindings.put("s", "marko");

    assertEquals(engine.eval("g.V().has('name',s).next()", bindings), g.V(convertToVertexId("marko")).next());

    try {
        engine.eval("g.V().has('name',s).next()");
        fail("This should have failed because s is no longer bound");
    } catch (Exception ex) {
        final Throwable t = ExceptionUtils.getRootCause(ex);
        assertEquals(MissingPropertyException.class, t.getClass());
        assertTrue(t.getMessage().startsWith("No such property: s for class"));
    }

}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:25,代码来源:GremlinGroovyScriptEngineOverGraphTest.java

示例10: shouldNotPreserveInstantiatedVariablesBetweenEvals

import groovy.lang.MissingPropertyException; //导入依赖的package包/类
@Test
public void shouldNotPreserveInstantiatedVariablesBetweenEvals() throws Exception {
    final ScriptEngines engines = new ScriptEngines(se -> {});
    engines.reload("gremlin-groovy", Collections.<String>emptySet(),
            Collections.<String>emptySet(), Collections.emptyMap());

    final Bindings localBindingsFirstRequest = new SimpleBindings();
    localBindingsFirstRequest.put("x", "there");
    assertEquals("herethere", engines.eval("z = 'here' + x", localBindingsFirstRequest, "gremlin-groovy"));

    try {
        final Bindings localBindingsSecondRequest = new SimpleBindings();
        engines.eval("z", localBindingsSecondRequest, "gremlin-groovy");
        fail("Should not have knowledge of z");
    } catch (Exception ex) {
        final Throwable root = ExceptionUtils.getRootCause(ex);
        assertThat(root, instanceOf(MissingPropertyException.class));
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:20,代码来源:ScriptEnginesTest.java

示例11: shouldPromoteDefinedVarsInInterpreterModeWithNoBindings

import groovy.lang.MissingPropertyException; //导入依赖的package包/类
@Test
public void shouldPromoteDefinedVarsInInterpreterModeWithNoBindings() throws Exception {
    final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(new InterpreterModeCustomizerProvider());
    engine.eval("def addItUp = { x, y -> x + y }");
    assertEquals(3, engine.eval("int xxx = 1 + 2"));
    assertEquals(4, engine.eval("yyy = xxx + 1"));
    assertEquals(7, engine.eval("def zzz = yyy + xxx"));
    assertEquals(4, engine.eval("zzz - xxx"));
    assertEquals("accessible-globally", engine.eval("if (yyy > 0) { def inner = 'should-stay-local'; outer = 'accessible-globally' }\n outer"));
    assertEquals("accessible-globally", engine.eval("outer"));

    try {
        engine.eval("inner");
        fail("Should not have been able to access 'inner'");
    } catch (Exception ex) {
        final Throwable root = ExceptionUtils.getRootCause(ex);
        assertThat(root, instanceOf(MissingPropertyException.class));
    }

    assertEquals(10, engine.eval("addItUp(zzz,xxx)"));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:22,代码来源:GremlinGroovyScriptEngineTest.java

示例12: shouldPromoteDefinedVarsInInterpreterModeWithBindings

import groovy.lang.MissingPropertyException; //导入依赖的package包/类
@Test
public void shouldPromoteDefinedVarsInInterpreterModeWithBindings() throws Exception {
    final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(new InterpreterModeCustomizerProvider());
    final Bindings b = new SimpleBindings();
    b.put("x", 2);
    engine.eval("def addItUp = { x, y -> x + y }", b);
    assertEquals(3, engine.eval("int xxx = 1 + x", b));
    assertEquals(4, engine.eval("yyy = xxx + 1", b));
    assertEquals(7, engine.eval("def zzz = yyy + xxx", b));
    assertEquals(4, engine.eval("zzz - xxx", b));
    assertEquals("accessible-globally", engine.eval("if (yyy > 0) { def inner = 'should-stay-local'; outer = 'accessible-globally' }\n outer", b));
    assertEquals("accessible-globally", engine.eval("outer", b));

    try {
        engine.eval("inner", b);
        fail("Should not have been able to access 'inner'");
    } catch (Exception ex) {
        final Throwable root = ExceptionUtils.getRootCause(ex);
        assertThat(root, instanceOf(MissingPropertyException.class));
    }

    assertEquals(10, engine.eval("addItUp(zzz,xxx)", b));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:24,代码来源:GremlinGroovyScriptEngineTest.java

示例13: errorHook

import groovy.lang.MissingPropertyException; //导入依赖的package包/类
/**
 * Error hook installed to Groovy shell.
 *
 * Will display exception that appeared during executing command. In most
 * cases we will simply delegate the call to printing throwable method,
 * however in case that we've received ClientError.CLIENT_0006 (server
 * exception), we will unwrap server issue and view only that as local
 * context shouldn't make any difference.
 *
 * @param t Throwable to be displayed
 */
public static void errorHook(Throwable t) {
  // Based on the kind of exception we are dealing with, let's provide different user experince
  if(t instanceof SqoopException && ((SqoopException)t).getErrorCode() == ShellError.SHELL_0006) {
    println("@|red Server has returned exception: |@");
    printThrowable(t.getCause(), isVerbose());
  } else if(t instanceof SqoopException && ((SqoopException)t).getErrorCode() == ShellError.SHELL_0003) {
    print("@|red Invalid command invocation: |@");
    // In most cases the cause will be actual parsing error, so let's print that alone
    if (t.getCause() != null) {
      println(t.getCause().getMessage());
    } else {
      println(t.getMessage());
    }
  } else if(t.getClass() == MissingPropertyException.class) {
    print("@|red Unknown command: |@");
    println(t.getMessage());
  } else {
    println("@|red Exception has occurred during processing command |@");
    printThrowable(t, isVerbose());
  }
}
 
开发者ID:vybs,项目名称:sqoop-on-spark,代码行数:33,代码来源:ThrowableDisplayer.java

示例14: getAt

import groovy.lang.MissingPropertyException; //导入依赖的package包/类
/**
 * Retrieve the value of the property by its index.
 * A negative index will count backwards from the last column.
 *
 * @param index is the number of the column to look at
 * @return the value of the property
 */
public Object getAt(int index) {
    try {
        // a negative index will count backwards from the last column.
        if (index < 0)
            index += result.size();
        Iterator it = result.values().iterator();
        int i = 0;
        Object obj = null;
        while ((obj == null) && (it.hasNext())) {
            if (i == index)
                obj = it.next();
            else
                it.next();
            i++;
        }
        return obj;
    }
    catch (Exception e) {
        throw new MissingPropertyException(Integer.toString(index), GroovyRowResult.class, e);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:29,代码来源:GroovyRowResult.java

示例15: extractNewValue

import groovy.lang.MissingPropertyException; //导入依赖的package包/类
private Object extractNewValue(Object newObject) {
    Object newValue;
    try {
        newValue = InvokerHelper.getProperty(newObject, propertyName);

    } catch (MissingPropertyException mpe) {
        //todo we should flag this when the path is created that this is a field not a prop...
        // try direct method...
        try {
            newValue = InvokerHelper.getAttribute(newObject, propertyName);
            if (newValue instanceof Reference) {
                newValue = ((Reference) newValue).get();
            }
        } catch (Exception e) {
            //LOGME?
            newValue = null;
        }
    }
    return newValue;
}
 
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:BindPath.java


注:本文中的groovy.lang.MissingPropertyException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。