<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
tools:context=".MainActivity" >
<TextView
android:id="@+id/instruction_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollHorizontally="true"
android:text="@string/Texto_de_abertura"
android:textColor="#00FF00" />
<TableRow>code<TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的代码.字符串Texto_de_abertura真的很大,并且它一直使用很多行来将整个字符串放在屏幕上,而不仅仅是一个我想要的水平滚动.
我有这个自定义对象:
data class Pair(
var first: String = "1",
var second: String = "2"
)
Run Code Online (Sandbox Code Playgroud)
现在我想用我的自动装配它application.yml:
my-properties:
my-integer-list:
- 1
- 2
- 3
my-map:
- "abc": "123"
- "test": "test"
pair:
first: "abc"
second: "123"
Run Code Online (Sandbox Code Playgroud)
使用这个类:
@Configuration
@ConfigurationProperties(prefix = "my-properties")
class ComplexProperties {
lateinit var myIntegerList: List<Int>
lateinit var myMap: Map<String, String>
lateinit var pair: Pair
}
Run Code Online (Sandbox Code Playgroud)
在添加之前Pair它工作正常,但是在我只得到之后Reason: lateinit property pair has not been initialized
这是我的main:
@SpringBootApplication
class DemoApplication
fun main(args: Array<String>) …Run Code Online (Sandbox Code Playgroud) 假设我有这个方法
public Optional<String> validateAndReturnErrorMessage(SomeEcommerceSale s) {
Optional<String> errorWithItem = validateItem(s.getItem());
if (errorWithItem.isPresent()) return errorWithItem;
Optional<String> errorWithPayment = validatePayment(s.getPayment());
if (errorWithPayment.isPresent()) return errorWithPayment;
// assume I have several other cases like the 2 above
return Optional.empty(); // meaning there were no errors
Run Code Online (Sandbox Code Playgroud)
我的问题是,由于OrElse and OrElseGetreturn<T>而不是Optional<T>,是否有一种本地方法可以将其重写为更实用的方式,而无需几个松散耦合的 return 语句?
编辑
我想一一检查验证,因为它们是外部且沉重的。这样,我只会调用必要的
我有一个显示实体列表的Angular应用程序,还有一个“显示更多”按钮,可增加页码并使用此方法:
Page<myEntity> result = myRepo.findByAttr(attr, page);
Run Code Online (Sandbox Code Playgroud)
我result将其格式化并通过REST的JSON发送。如果没有其他页面可供获取,我想禁用“显示更多”按钮。有一种“框架”特定的方式来检索此数字,或者我应该使用findAll()并计算该列表?
我有这种依赖性:
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
哪个版本由
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
</parent>
Run Code Online (Sandbox Code Playgroud)
我有这块:
import javax.validation.constraints.NotNull;
//other imports ommited
@Component
@ConfigurationProperties(prefix = "collector")
public class CollectorProperties {
@NotNull
private String urlCDI;
//getters and setters
}
Run Code Online (Sandbox Code Playgroud)
我SpringApplication.run班上有这样的香料:
@SpringBootApplication
@EnableConfigurationProperties
@ComponentScan({ "otherPackages", "packageWhereCollectorPropertiesIs" })
Run Code Online (Sandbox Code Playgroud)
当我有application.properties这条线时
collector.urlCDI=https://www.cetip.com.br/Home
Run Code Online (Sandbox Code Playgroud)
它可以像在其他春豆中一样发挥作用:
//@Component class variables:
@Autowired
private CollectorProperties props;
//inside some method
URL url = new URL(props.getUrlCDI());
Run Code Online (Sandbox Code Playgroud)
但是,当我删除它或更改属性键时,会得到很多NPE而不是验证错误。我做错了什么?不hibernate-validator包含javax.validation.constraints.NotNull接口的实现吗?
在 REST API 请求 json 正文中,我正在传递"argument1":true并且可以正常工作。但我发现当使用任何数字时,它都会将其转换为 true。只有在显式使用时,false它才会变为 false。我正在使用 Spring BootResponseEntityExceptionHandler并@RestControllerAdvice处理所有异常。转换534为时如何抛出任何异常true?
我想应用一个计算方法,如果键存在则增加值,否则放 1。
Map<Integer, Integer> map = new HashMap<>();
Run Code Online (Sandbox Code Playgroud)
我不明白为什么
for (int i = 0; i < 10; i++) map.compute(1, (k, v) -> v != null ? v++ : 1);
Run Code Online (Sandbox Code Playgroud)
结果{1=1}
和
for (int i = 0; i < 10; i++) map.compute(1, (k, v) -> (v != null ? v : 0) + 1);
Run Code Online (Sandbox Code Playgroud)
结果{1=10}?
我对第一种情况的理解是:
k,则从中获取结果v++并将其放回原处,否则用 1 填充而秒的情况是:
ksave的值v+1,否则 save 0+1,它也是 1为什么在这种情况下运行v++ …
我找到了一些 postgresql 触发器教程。有这个示例函数:
CREATE OR REPLACE FUNCTION add_log_trigg_function() RETURNS trigger AS
$BODY$
DECLARE
account_type varchar;
BEGIN
IF (TG_TABLE_NAME = 'account_current') THEN
account_type := 'Current';
RAISE NOTICE 'TRIGER called on %', TG_TABLE_NAME;
ELSIF (TG_TABLE_NAME = 'account_savings') THEN
account_type := 'Savings';
RAISE NOTICE 'TRIGER called on %', TG_TABLE_NAME;
END IF;
RETURN null;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION add_log_trigg_function()
OWNER TO postgres;
Run Code Online (Sandbox Code Playgroud)
我知道这会$BODY$启动身体功能。但是为什么要命名呢?这个名字BODY可以或通常用于其他地方吗?除了LANGUAGE,COST和ALTER FUNCTION命令之外,还有哪些命令通常留在外面$BODY$?
我试图让按钮在按下时打印一个字符串,并在释放时打印另一个。我知道command属性和bind方法,但我想知道是否可以仅使用属性来完成它,或者我是否必须使用方法。用这段代码:
class motor:
def __init__(eleMesmo, eixo , valorZero):
eleMesmo.eixo = eixo
eleMesmo.zero = valorZero
def aumenta(self):
print(self.eixo + str(self.zero+5))
def diminui(self):
print(self.eixo + str(self.zero-5))
def para(self):
print(self.eixo + str(self.zero))
eixox = motor('x',90)
eixoy = motor('y',90)
class Interface:
def __init__(elemesmo, widget):
quadro = Frame(widget)
quadro.pack()
elemesmo.aumentarY = Button(quadro,text="Aumentar Y",height=10,width=20,command=eixoy.aumenta)
elemesmo.aumentarY.pack(side=TOP)
elemesmo.diminuirY = Button(quadro,text="Diminuir Y",height=10,width=20,command=eixoy.diminui)
Run Code Online (Sandbox Code Playgroud)
我可以在按下按钮时调用aumenta对象的方法。我想在释放按钮时调用对象的方法。我该怎么做?eixo yaumentarYparaeixo yaumentarY
在尝试理解并应用如何创建一个找到XInput设备的ID的程序的答案时,我发现的代码似乎不符合bash的文档语法.
~记录为按位否定 - 一个只采用一个参数的数学运算符 - 但它在这里$0作为一个参数和一个字符串作为另一个运行.$0 记录为引用脚本本身的名称,但引用该名称在此代码应该执行的操作的上下文中没有意义.我在这里错过了什么?
ids=$(xinput --list | awk -v search="$SEARCH" \
'$0 ~ search {match($0, /id=[0-9]+/);\
if (RSTART) \
print substr($0, RSTART+3, RLENGTH-3)\
}'\
)
Run Code Online (Sandbox Code Playgroud) 我有以下查询:
select t1.a,
t1.b,
t2.c,
....
from table1 t1,
table2 t2,
...
where ...
and condition1
and condition2
and
case
when (t1.a in ('aa', 'bb') and
t1.e = t2.e) then
true
when (t1.a in ('cc', 'dd') and
t1.e = t2.f) then
true
else
false
end;
Run Code Online (Sandbox Code Playgroud)
我想确定使用列值的where子句.上面的查询ORA-00920 invalid relational operator在最后一行返回.我在这里检查调整我的条款.如果t1.a是aa或bb,我必须只选择行,如果t1.e = t2.e返回true.现在,如果t1.a是cc或dd,那么它必须只选择行t1.e = t2.f,比较不同的列.没有程序可以做到吗?
我正在使用这个官方指南在我的Ubuntu 16.04(Xenial Xerus)上安装MongoDB.在Run MongoDB Community Edition我
无法启动mongod.service:找不到单位mongod.service.
打字后sudo service mongod start.我只是调查了一下/var/log/mongodb,它是空的.在此问题之前我没有任何其他错误.我怎样才能解决这个问题?