mirror of
https://github.com/HighCapable/YukiReflection.git
synced 2025-09-06 10:45:46 +08:00
style: optimize code
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
* This file is created by fankes on 2022/4/3.
|
||||
* This file is Modified by fankes on 2023/1/21.
|
||||
*/
|
||||
@file:Suppress("OPT_IN_IS_NOT_ENABLED", "EXPERIMENTAL_IS_NOT_ENABLED", "unused")
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.highcapable.yukireflection.annotation
|
||||
|
||||
|
@@ -26,7 +26,7 @@
|
||||
* This file is created by fankes on 2022/4/3.
|
||||
* This file is Modified by fankes on 2023/1/21.
|
||||
*/
|
||||
@file:Suppress("OPT_IN_IS_NOT_ENABLED", "EXPERIMENTAL_IS_NOT_ENABLED")
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.highcapable.yukireflection.annotation
|
||||
|
||||
|
@@ -150,7 +150,7 @@ class CurrentClass @PublishedApi internal constructor(@PublishedApi internal val
|
||||
inline fun method(initiate: MethodConditions) =
|
||||
superClassSet.method(initiate).result { if (isShutErrorPrinting) ignored() }.get(instance)
|
||||
|
||||
override fun toString() = "CurrentClass super [${superClassSet}]"
|
||||
override fun toString() = "CurrentClass super [$superClassSet]"
|
||||
}
|
||||
|
||||
override fun toString() = "CurrentClass [$classSet]"
|
||||
|
@@ -39,10 +39,36 @@ import com.highcapable.yukireflection.finder.members.ConstructorFinder
|
||||
import com.highcapable.yukireflection.finder.members.FieldFinder
|
||||
import com.highcapable.yukireflection.finder.members.MethodFinder
|
||||
import com.highcapable.yukireflection.finder.tools.ReflectionTool
|
||||
import com.highcapable.yukireflection.finder.type.factory.*
|
||||
import com.highcapable.yukireflection.type.java.*
|
||||
import com.highcapable.yukireflection.finder.type.factory.ClassConditions
|
||||
import com.highcapable.yukireflection.finder.type.factory.ConstructorConditions
|
||||
import com.highcapable.yukireflection.finder.type.factory.FieldConditions
|
||||
import com.highcapable.yukireflection.finder.type.factory.MethodConditions
|
||||
import com.highcapable.yukireflection.finder.type.factory.ModifierConditions
|
||||
import com.highcapable.yukireflection.type.java.AnyClass
|
||||
import com.highcapable.yukireflection.type.java.BooleanClass
|
||||
import com.highcapable.yukireflection.type.java.BooleanType
|
||||
import com.highcapable.yukireflection.type.java.ByteClass
|
||||
import com.highcapable.yukireflection.type.java.ByteType
|
||||
import com.highcapable.yukireflection.type.java.CharClass
|
||||
import com.highcapable.yukireflection.type.java.CharType
|
||||
import com.highcapable.yukireflection.type.java.DoubleClass
|
||||
import com.highcapable.yukireflection.type.java.DoubleType
|
||||
import com.highcapable.yukireflection.type.java.FloatClass
|
||||
import com.highcapable.yukireflection.type.java.FloatType
|
||||
import com.highcapable.yukireflection.type.java.IntClass
|
||||
import com.highcapable.yukireflection.type.java.IntType
|
||||
import com.highcapable.yukireflection.type.java.LongClass
|
||||
import com.highcapable.yukireflection.type.java.LongType
|
||||
import com.highcapable.yukireflection.type.java.ShortClass
|
||||
import com.highcapable.yukireflection.type.java.ShortType
|
||||
import com.highcapable.yukireflection.type.java.UnitClass
|
||||
import com.highcapable.yukireflection.type.java.UnitType
|
||||
import dalvik.system.BaseDexClassLoader
|
||||
import java.lang.reflect.*
|
||||
import java.lang.reflect.Constructor
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Member
|
||||
import java.lang.reflect.Method
|
||||
import java.lang.reflect.ParameterizedType
|
||||
|
||||
/**
|
||||
* 写出当前 [ClassLoader] 下所有 [Class] 名称数组
|
||||
|
@@ -172,11 +172,11 @@ internal class ClassRulesData internal constructor(
|
||||
|
||||
override val isInitialize
|
||||
get() = super.isInitialize || fromPackages.isNotEmpty() || fullName != null || simpleName != null || singleName != null ||
|
||||
fullNameConditions != null || simpleNameConditions != null || singleNameConditions != null || isAnonymousClass != null ||
|
||||
isNoExtendsClass != null || isNoImplementsClass != null || extendsClass.isNotEmpty() || enclosingClass.isNotEmpty() ||
|
||||
memberRules.isNotEmpty() || fieldRules.isNotEmpty() || methodRules.isNotEmpty() || constroctorRules.isNotEmpty()
|
||||
fullNameConditions != null || simpleNameConditions != null || singleNameConditions != null || isAnonymousClass != null ||
|
||||
isNoExtendsClass != null || isNoImplementsClass != null || extendsClass.isNotEmpty() || enclosingClass.isNotEmpty() ||
|
||||
memberRules.isNotEmpty() || fieldRules.isNotEmpty() || methodRules.isNotEmpty() || constroctorRules.isNotEmpty()
|
||||
|
||||
override fun toString() = "[$fromPackages][$fullName][$simpleName][$singleName][$fullNameConditions][$simpleNameConditions]" +
|
||||
"[$singleNameConditions][$modifiers][$isAnonymousClass][$isNoExtendsClass][$isNoImplementsClass][$extendsClass][$implementsClass]" +
|
||||
"[$enclosingClass][$memberRules][$fieldRules][$methodRules][$constroctorRules]" + super.toString()
|
||||
"[$singleNameConditions][$modifiers][$isAnonymousClass][$isNoExtendsClass][$isNoImplementsClass][$extendsClass][$implementsClass]" +
|
||||
"[$enclosingClass][$memberRules][$fieldRules][$methodRules][$constroctorRules]" + super.toString()
|
||||
}
|
@@ -34,7 +34,11 @@ import com.highcapable.yukireflection.bean.VariousClass
|
||||
import com.highcapable.yukireflection.finder.classes.rules.base.BaseRules
|
||||
import com.highcapable.yukireflection.finder.classes.rules.result.MemberRulesResult
|
||||
import com.highcapable.yukireflection.finder.members.data.MethodRulesData
|
||||
import com.highcapable.yukireflection.finder.type.factory.*
|
||||
import com.highcapable.yukireflection.finder.type.factory.CountConditions
|
||||
import com.highcapable.yukireflection.finder.type.factory.ModifierConditions
|
||||
import com.highcapable.yukireflection.finder.type.factory.NameConditions
|
||||
import com.highcapable.yukireflection.finder.type.factory.ObjectConditions
|
||||
import com.highcapable.yukireflection.finder.type.factory.ObjectsConditions
|
||||
import com.highcapable.yukireflection.type.defined.UndefinedType
|
||||
import com.highcapable.yukireflection.type.defined.VagueType
|
||||
import java.lang.reflect.Method
|
||||
|
@@ -37,7 +37,12 @@ import com.highcapable.yukireflection.finder.base.BaseFinder
|
||||
import com.highcapable.yukireflection.finder.base.MemberBaseFinder
|
||||
import com.highcapable.yukireflection.finder.members.data.MethodRulesData
|
||||
import com.highcapable.yukireflection.finder.tools.ReflectionTool
|
||||
import com.highcapable.yukireflection.finder.type.factory.*
|
||||
import com.highcapable.yukireflection.finder.type.factory.CountConditions
|
||||
import com.highcapable.yukireflection.finder.type.factory.MethodConditions
|
||||
import com.highcapable.yukireflection.finder.type.factory.ModifierConditions
|
||||
import com.highcapable.yukireflection.finder.type.factory.NameConditions
|
||||
import com.highcapable.yukireflection.finder.type.factory.ObjectConditions
|
||||
import com.highcapable.yukireflection.finder.type.factory.ObjectsConditions
|
||||
import com.highcapable.yukireflection.log.yLoggerW
|
||||
import com.highcapable.yukireflection.type.defined.UndefinedType
|
||||
import com.highcapable.yukireflection.type.defined.VagueType
|
||||
|
@@ -62,7 +62,7 @@ internal class ConstructorRulesData internal constructor(
|
||||
|
||||
override val isInitialize
|
||||
get() = super.isInitializeOfSuper || paramTypes != null || paramTypesConditions != null || paramCount >= 0 ||
|
||||
paramCountRange.isEmpty().not() || paramCountConditions != null
|
||||
paramCountRange.isEmpty().not() || paramCountConditions != null
|
||||
|
||||
override fun toString() = "[$paramTypes][$paramTypesConditions][$paramCount][$paramCountRange]" + super.toString()
|
||||
}
|
@@ -76,9 +76,9 @@ internal class MethodRulesData internal constructor(
|
||||
|
||||
override val isInitialize
|
||||
get() = super.isInitializeOfSuper || name.isNotBlank() || nameConditions != null || paramTypes != null || paramTypesConditions != null ||
|
||||
paramCount >= 0 || paramCountRange.isEmpty().not() || paramCountConditions != null ||
|
||||
returnType != null || returnTypeConditions != null
|
||||
paramCount >= 0 || paramCountRange.isEmpty().not() || paramCountConditions != null ||
|
||||
returnType != null || returnTypeConditions != null
|
||||
|
||||
override fun toString() = "[$name][$nameConditions][$paramTypes][$paramTypesConditions][$paramCount]" +
|
||||
"[$paramCountRange][$returnType][$returnTypeConditions]" + super.toString()
|
||||
"[$paramCountRange][$returnType][$returnTypeConditions]" + super.toString()
|
||||
}
|
@@ -32,7 +32,12 @@ package com.highcapable.yukireflection.finder.tools
|
||||
|
||||
import android.util.ArrayMap
|
||||
import com.highcapable.yukireflection.YukiReflection
|
||||
import com.highcapable.yukireflection.factory.*
|
||||
import com.highcapable.yukireflection.factory.classOf
|
||||
import com.highcapable.yukireflection.factory.current
|
||||
import com.highcapable.yukireflection.factory.field
|
||||
import com.highcapable.yukireflection.factory.hasClass
|
||||
import com.highcapable.yukireflection.factory.hasExtends
|
||||
import com.highcapable.yukireflection.factory.toClass
|
||||
import com.highcapable.yukireflection.finder.base.data.BaseRulesData
|
||||
import com.highcapable.yukireflection.finder.classes.data.ClassRulesData
|
||||
import com.highcapable.yukireflection.finder.members.data.ConstructorRulesData
|
||||
@@ -46,13 +51,19 @@ import com.highcapable.yukireflection.type.java.DalvikBaseDexClassLoader
|
||||
import com.highcapable.yukireflection.type.java.NoClassDefFoundErrorClass
|
||||
import com.highcapable.yukireflection.type.java.NoSuchFieldErrorClass
|
||||
import com.highcapable.yukireflection.type.java.NoSuchMethodErrorClass
|
||||
import com.highcapable.yukireflection.utils.*
|
||||
import com.highcapable.yukireflection.utils.conditions
|
||||
import com.highcapable.yukireflection.utils.findLastIndex
|
||||
import com.highcapable.yukireflection.utils.lastIndex
|
||||
import com.highcapable.yukireflection.utils.let
|
||||
import com.highcapable.yukireflection.utils.runOrFalse
|
||||
import com.highcapable.yukireflection.utils.takeIf
|
||||
import com.highcapable.yukireflection.utils.value
|
||||
import dalvik.system.BaseDexClassLoader
|
||||
import java.lang.reflect.Constructor
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Member
|
||||
import java.lang.reflect.Method
|
||||
import java.util.*
|
||||
import java.util.Enumeration
|
||||
import kotlin.math.abs
|
||||
|
||||
/**
|
||||
@@ -539,7 +550,7 @@ internal object ReflectionTool {
|
||||
* @return [Boolean] 返回是否成立
|
||||
*/
|
||||
private fun Pair<Int, Boolean>?.compare(need: Int, last: Int) = this == null || ((first >= 0 && first == need && second) ||
|
||||
(first < 0 && abs(first) == (last - need) && second) || (last == need && second.not()))
|
||||
(first < 0 && abs(first) == (last - need) && second) || (last == need && second.not()))
|
||||
|
||||
/**
|
||||
* 比较位置下标的前后顺序
|
||||
@@ -550,8 +561,8 @@ internal object ReflectionTool {
|
||||
private fun Pair<Int, Boolean>?.compare(need: Int, last: Int, result: (Boolean) -> Unit) {
|
||||
if (this == null) return
|
||||
((first >= 0 && first == need && second) ||
|
||||
(first < 0 && abs(first) == (last - need) && second) ||
|
||||
(last == need && second.not())).also(result)
|
||||
(first < 0 && abs(first) == (last - need) && second) ||
|
||||
(last == need && second.not())).also(result)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -30,7 +30,7 @@
|
||||
|
||||
package com.highcapable.yukireflection.type.android
|
||||
|
||||
import android.app.*
|
||||
import android.app.* // ktlint-disable no-wildcard-imports
|
||||
import android.appwidget.AppWidgetHost
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.appwidget.AppWidgetProvider
|
||||
|
@@ -30,10 +30,33 @@
|
||||
|
||||
package com.highcapable.yukireflection.type.android
|
||||
|
||||
import android.graphics.*
|
||||
import android.graphics.drawable.*
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.ColorMatrix
|
||||
import android.graphics.ColorMatrixColorFilter
|
||||
import android.graphics.Matrix
|
||||
import android.graphics.NinePatch
|
||||
import android.graphics.Outline
|
||||
import android.graphics.Paint
|
||||
import android.graphics.Point
|
||||
import android.graphics.PointF
|
||||
import android.graphics.Rect
|
||||
import android.graphics.RectF
|
||||
import android.graphics.Typeface
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.graphics.drawable.Icon
|
||||
import android.os.Build
|
||||
import android.text.*
|
||||
import android.text.Editable
|
||||
import android.text.GetChars
|
||||
import android.text.Spannable
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.TextPaint
|
||||
import android.text.TextUtils
|
||||
import android.text.TextWatcher
|
||||
import android.util.Size
|
||||
import android.util.SizeF
|
||||
import com.highcapable.yukireflection.factory.classOf
|
||||
|
@@ -30,17 +30,51 @@
|
||||
|
||||
package com.highcapable.yukireflection.type.android
|
||||
|
||||
import android.animation.*
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorSet
|
||||
import android.animation.ObjectAnimator
|
||||
import android.animation.PropertyValuesHolder
|
||||
import android.animation.ValueAnimator
|
||||
import android.appwidget.AppWidgetHostView
|
||||
import android.util.AttributeSet
|
||||
import android.view.*
|
||||
import android.view.GestureDetector
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MotionEvent
|
||||
import android.view.Surface
|
||||
import android.view.SurfaceView
|
||||
import android.view.TextureView
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewParent
|
||||
import android.view.ViewPropertyAnimator
|
||||
import android.view.ViewStructure
|
||||
import android.view.ViewStub
|
||||
import android.view.animation.AlphaAnimation
|
||||
import android.view.animation.Animation
|
||||
import android.view.animation.TranslateAnimation
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import android.widget.*
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.AutoCompleteTextView
|
||||
import android.widget.BaseAdapter
|
||||
import android.widget.Button
|
||||
import android.widget.CheckBox
|
||||
import android.widget.CompoundButton
|
||||
import android.widget.EditText
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageButton
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.ListAdapter
|
||||
import android.widget.ListView
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.RemoteViews
|
||||
import android.widget.RemoteViews.RemoteView
|
||||
import android.widget.TextClock
|
||||
import android.widget.TextView
|
||||
import android.widget.VideoView
|
||||
import android.widget.ViewAnimator
|
||||
import com.highcapable.yukireflection.factory.classOf
|
||||
|
||||
/**
|
||||
|
@@ -40,7 +40,7 @@ import dalvik.system.InMemoryDexClassLoader
|
||||
import dalvik.system.PathClassLoader
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.io.*
|
||||
import java.io.* // ktlint-disable no-wildcard-imports
|
||||
import java.lang.ref.Reference
|
||||
import java.lang.ref.WeakReference
|
||||
import java.lang.reflect.Constructor
|
||||
|
@@ -199,7 +199,7 @@ internal class Conditions<T>(internal var value: T) {
|
||||
*/
|
||||
private val result by lazy {
|
||||
optConditions.takeIf { it.isNotEmpty() }?.any { it } == true ||
|
||||
andConditions.takeIf { it.isNotEmpty() }?.any { it.not() }?.not() == true
|
||||
andConditions.takeIf { it.isNotEmpty() }?.any { it.not() }?.not() == true
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user