gpt4 book ai didi

string - groovy 脚本列表包含字符串值

转载 作者:行者123 更新时间:2023-12-01 21:59:41 24 4
gpt4 key购买 nike

我有一个 groovy 脚本,它检查值列表中屏幕上字段的值(如果存在)。

import com.atlassian.jira.component.ComponentAccessor;
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.user.ApplicationUser;
import java.lang.Object

def groupManager = ComponentAccessor.getGroupManager();
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def eManagerCF = customFieldManager.getCustomFieldObjectByName("Ek Manager")
def dedManagerCF = customFieldManager.getCustomFieldObjectByName("Ded Manager")
def depManagerCF = customFieldManager.getCustomFieldObjectByName("Dep Manager ")

String eManager = issue.getCustomFieldValue(eManagerCF)
String dedManager = issue.getCustomFieldValue(dedManagerCF)
String depManager = issue.getCustomFieldValue(depManagerCF)

if (eManager) {
eManager = eManager.trim()
}

if (dedManager) {
dedManager = dedManager.trim()
}

if (depManager) {
depManager = depManager.trim()
}

cfValues['2. Onay'] ? .value == null && cfValues['1.Adim '] ? .value != "Helpdesk" && cfValues['1. Onay '] ? .value == "Ilgili Yönetici " &&
(!groupManager.getUsersInGroup('ITSM Onaya Gitmeyecek Personeller ').contains(eManager) ||
!groupManager.getUserNamesInGroup('ITSM Onaya Gitmeyecek Personeller ').contains(dedManager) ||
!groupManager.getUsersInGroup('ITSM Onaya Gitmeyecek Personeller ').contains(depManager))

所以我的问题是: 字符串 dedManager= issue.getCustomFieldValue(dedManagerCF) 返回 aaa.bbb@xx.com

groupManager.getUsersInGroup('ITSM Onaya Gitmeyecek Personeller)返回包含 Aaa.Bbb@xx.com 等用户名的列表

所以方法 groupManager.getUsersInGroup('ITSM Onaya Gitmeyecek Personeller').contains(depManager)) 总是返回 false

你能帮忙吗?

最佳答案

为了简化您的问题:如何在忽略大小写的列表中查找字符串值。

def str = 'Aaa.Bbb@xx.com'
def list = ['xxx.yyy@zz.com','aaa.bbb@xx.com']

if( list.find{e-> e.equalsIgnoreCase(str)} ){
println "found"
}

或者如果您确定列表始终包含小写项,只需在应用 contains 之前将字符串转换为小写即可

def str = 'Aaa.Bbb@xx.com'
def list = ['xxx.yyy@zz.com','aaa.bbb@xx.com']

str = str.toLowerCase()
if( str in list ){
println "found"
}

关于string - groovy 脚本列表包含字符串值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54088178/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com