Redian新闻
>
找工作怎么这么难?
avatar
Y*G
2
假定我自己定义了一个qualifier: Year用来描述汽车制造的年份
@Qualifier
public @interface Year {
int value();
}
如果我需要2010年生产的汽车,我可以用
...
@Autowired
@Year(2010)
private Car car;
...
我怎么可以表达“我要2010年以后生产的汽车”?
下面的写法不工作:
...
@Autowired
@Year(value>2010)
private Car car;
...
avatar
s*l
3
从去年6月开始到现在只拿到一个onsite(自我感觉是陪跑),基本没有什么消息,工
作出来的本来就少,要求又高,学到化学Phd了,怎么一点价值和认同感都感觉不到?
不知道自己还能干什么了。。。。家里的那位是我师兄,这一家可怎么办啊。。。。
avatar
Y*y
4
嗯,短,但是剧情流畅简洁,非常棒。
avatar
Y*G
5
我的前提条件是容器的配置是正确的,2010以后的汽车只有一辆,不会没有。autowire
不会出现问题。
avatar
e*2
6
春节愉快!
快乐过了今天再说

【在 s****l 的大作中提到】
: 从去年6月开始到现在只拿到一个onsite(自我感觉是陪跑),基本没有什么消息,工
: 作出来的本来就少,要求又高,学到化学Phd了,怎么一点价值和认同感都感觉不到?
: 不知道自己还能干什么了。。。。家里的那位是我师兄,这一家可怎么办啊。。。。

avatar
z*e
7
等下,spring允许你自己写annotation了?
你用spring的话,应该用不到@interface吧?
avatar
s*r
8
搬家去德克萨斯,阿拉斯加,达科他州?

【在 s****l 的大作中提到】
: 从去年6月开始到现在只拿到一个onsite(自我感觉是陪跑),基本没有什么消息,工
: 作出来的本来就少,要求又高,学到化学Phd了,怎么一点价值和认同感都感觉不到?
: 不知道自己还能干什么了。。。。家里的那位是我师兄,这一家可怎么办啊。。。。

avatar
o*e
9
跟spring有毛关系
avatar
l*3
10
找码公试试。会计算机打字的都年薪10w
avatar
o*e
11
yes, you can create a custom qualifier annotation, all you need to do is to
define an annotation that’s itself annotated with @Qualifier.

【在 z****e 的大作中提到】
: 等下,spring允许你自己写annotation了?
: 你用spring的话,应该用不到@interface吧?

avatar
a*o
12
你说的是20年前了吧。楼主要是没有一定的编程经验,马工肯定没戏。实在不行的话,
可以赶快申请去读个CS master。要自费读两年。出来后也只有一小部分人能进FLAG赚
大钱,不过绝大多数人在个一般的公司赚个10万年薪还是很轻松的

【在 l**********3 的大作中提到】
: 找码公试试。会计算机打字的都年薪10w
avatar
o*e
13
要实现lz的想法办法有几个。没那么复杂,lz想多了。
这跟spring真没关系。lz你的year interface只有一个int 变量,你给“value>2010”
这个进去,算啥?必须是int才行啊。
你这个写法,就不是java了,是人类语言了。lol。
直接写多一个annotation最简单,
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.beans.factory.annotation.Qualifier;
@Target({ElementType.FIELD,ElementType.PARAMETER,ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public @interface NewerThanYearTwoOTen{
}
@NewerThanYearTwoOTen
@Year(2018)
public class NewBMWBENZshittyCar implements Car{
...
}
@Autowired
@NewerThanYearTwoOTen
private Car car;
简单粗暴。bingo, you get a NewBMWBENZshittyCar.
或者用你的办法,就得这样。跟spring没关系了。
if (obj.isAnnotationPresent(year.class)) {
Annotation annotation = obj.getAnnotation(Year.class);
Year year = (Year) annotation;
if(year.value > 2010){
//do whatever you want here;
}
}
avatar
L*u
14
chemistry is dead?
avatar
o*e
15
马来个鸡蛋,我是不是闲的很蛋痛?nnd。全看pornhub算了。
avatar
r*e
16
这个我觉得是一定的吧,化学的博士显然很难,做好心理准备就好。而且很可能面临去
公司后工资仍然比很多其他行业低,既然选择了这行,就要有这个心态

【在 s****l 的大作中提到】
: 从去年6月开始到现在只拿到一个onsite(自我感觉是陪跑),基本没有什么消息,工
: 作出来的本来就少,要求又高,学到化学Phd了,怎么一点价值和认同感都感觉不到?
: 不知道自己还能干什么了。。。。家里的那位是我师兄,这一家可怎么办啊。。。。

avatar
d*i
17
楼主明显想多了,这个用annotation显然是overkill了,而且由于用了reflection而使
得性能下降。最简单粗暴的就是把year放到Car里面, 这样既符合面向对象的基本原则
,又不会因为滥用annotation和反射而导致性能下降:
public class Car {
private int year;

public boolean isGreaterThanGivenYear(int given) {
return year > given ? true : false;
}

//other methods.....
}
avatar
d*u
18
理想比什么都重要

【在 s****l 的大作中提到】
: 从去年6月开始到现在只拿到一个onsite(自我感觉是陪跑),基本没有什么消息,工
: 作出来的本来就少,要求又高,学到化学Phd了,怎么一点价值和认同感都感觉不到?
: 不知道自己还能干什么了。。。。家里的那位是我师兄,这一家可怎么办啊。。。。

avatar
Y*G
19
把Year放到Car里面去,那怎么用autowired呢?
avatar
p*g
20
吹吧。

【在 l**********3 的大作中提到】
: 找码公试试。会计算机打字的都年薪10w
avatar
Y*G
21
假定我自己定义了一个qualifier: Year用来描述汽车制造的年份
@Qualifier
public @interface Year {
int value();
}
如果我需要2010年生产的汽车,我可以用
...
@Autowired
@Year(2010)
private Car car;
...
我怎么可以表达“我要2010年以后生产的汽车”?
下面的写法不工作:
...
@Autowired
@Year(value>2010)
private Car car;
...
avatar
Y*G
22
我的前提条件是容器的配置是正确的,2010以后的汽车只有一辆,不会没有。autowire
不会出现问题。
avatar
z*e
23
等下,spring允许你自己写annotation了?
你用spring的话,应该用不到@interface吧?
avatar
o*e
24
跟spring有毛关系
avatar
o*e
25
yes, you can create a custom qualifier annotation, all you need to do is to
define an annotation that’s itself annotated with @Qualifier.

【在 z****e 的大作中提到】
: 等下,spring允许你自己写annotation了?
: 你用spring的话,应该用不到@interface吧?

avatar
o*e
26
要实现lz的想法办法有几个。没那么复杂,lz想多了。
这跟spring真没关系。lz你的year interface只有一个int 变量,你给“value>2010”
这个进去,算啥?必须是int才行啊。
你这个写法,就不是java了,是人类语言了。lol。
直接写多一个annotation最简单,
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.beans.factory.annotation.Qualifier;
@Target({ElementType.FIELD,ElementType.PARAMETER,ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public @interface NewerThanYearTwoOTen{
}
@NewerThanYearTwoOTen
@Year(2018)
public class NewBMWBENZshittyCar implements Car{
...
}
@Autowired
@NewerThanYearTwoOTen
private Car car;
简单粗暴。bingo, you get a NewBMWBENZshittyCar.
或者用你的办法,就得这样。跟spring没关系了。
if (obj.isAnnotationPresent(year.class)) {
Annotation annotation = obj.getAnnotation(Year.class);
Year year = (Year) annotation;
if(year.value > 2010){
//do whatever you want here;
}
}
avatar
o*e
27
马来个鸡蛋,我是不是闲的很蛋痛?nnd。全看pornhub算了。
avatar
d*i
28
楼主明显想多了,这个用annotation显然是overkill了,而且由于用了reflection而使
得性能下降。最简单粗暴的就是把year放到Car里面, 这样既符合面向对象的基本原则
,又不会因为滥用annotation和反射而导致性能下降:
public class Car {
private int year;

public boolean isGreaterThanGivenYear(int given) {
return year > given ? true : false;
}

//other methods.....
}
avatar
Y*G
29
把Year放到Car里面去,那怎么用autowired呢?
avatar
h*8
30
ben mo dao zhi
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。