这个Java片段的Perl等价物是什么?(Perl术语中的Java解释)

jm6*_*666 3 java perl moose

任何人都可以帮我"翻译"这个java片段到perl/Moose术语吗?尝试理解java对象语法/逻辑,我只知道perl.

基于评论编辑:段即将到来的形式XWiki实现包- http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents ...这是太大了分析,所以怎么样的剩余码?是可能的(仅用于解释 - 忽略@lines?'@ something'的一般含义是什么?

@Component("hello")
public class HelloWorldScriptService implements ScriptService
{
    @Requirement
    private HelloWorld helloWorld;

    public String greet()
    {
        return this.helloWorld.sayHello();
    }
}
Run Code Online (Sandbox Code Playgroud)

寻找类似下一个perl片段的东西,但不知道"@Component,@ Request - etc :(

package HelloWorldScriptService;
use Moose;
sub greet {
    return $self->
}
Run Code Online (Sandbox Code Playgroud)

存在一些用perl-ish术语解释java的文档?(至少,一些基础知识)

plu*_*lus 5

不确定@Component,但还有更多:

package HelloWorld;
use Moose;

sub say_hello {
   print "Hello";
}

1;

package HelloWorldScriptService;
use Moose;

has 'hello_world' => ( is => 'rw', isa => 'HelloWorld' );

# TODO - will need to instantiate the hello_world object somewhere...

sub greet {
   my ($self) = @_;
   return $self->hello_world->say_hello();
}

1;
Run Code Online (Sandbox Code Playgroud)

既然helloWorld是原始的私有属性,你可能想要在名称'hello_world'前面添加下划线(并添加init_args => undef) - 这不会像Java一样强制执行隐私,但会向任何查看代码的人显示它在概念上是私有的(并阻止在new()上设置)