Skip to content

Commit

Permalink
ignore iml,
Browse files Browse the repository at this point in the history
为 unique 添加默认类型参数
  • Loading branch information
berberman committed Dec 6, 2018
1 parent 2f5ed66 commit c9a7a6e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 78 deletions.
75 changes: 1 addition & 74 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,80 +1,7 @@
# Created by .ignore support plugin (hsz.mobi)
### Gradle template
.gradle
/build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache

# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties
### Kotlin template
# Compiled class file

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### JetBrains template
.idea

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

*.iml
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ sudo: true
before_install:
# 赋予执行权限
- chmod a+x gradlew
- chmod a+x deploy.sh

script:
# 清理、生成、测试、文档
Expand All @@ -32,7 +33,7 @@ deploy:
tags: true

- provider: script
script: ./gradlew clean build dokka bintrayUpload -PbintrayUser $bintrayUser -PbintrayKey $bintrayKey -PdryRun=false
script: bash ./deploy.sh
on:
tags: true

Expand Down
1 change: 1 addition & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./gradlew clean build dokka bintrayUpload -PbintrayUser $bintrayUser -PbintrayKey $bintrayKey -PdryRun=false
1 change: 0 additions & 1 deletion gradle.properties

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ import kotlin.reflect.KClass
* @param which 要找的组件类型
*/
class ComponentNotExistException(which: KClass<out Component>) :
RuntimeException("cannot find this org.mechdancer.dependency: ${which.qualifiedName}")
RuntimeException("Cannot find this component: ${which.qualifiedName}")
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.mechdancer.dependency.unique

import org.mechdancer.dependency.Component
import java.lang.reflect.ParameterizedType
import kotlin.reflect.KClass
import kotlin.reflect.full.safeCast

Expand All @@ -11,7 +12,14 @@ import kotlin.reflect.full.safeCast
* 泛型 [T] 可保证此类型来自这个实现类
*/
abstract class UniqueComponent<T : UniqueComponent<T>>
(private val type: KClass<T>) : Component {
(type: KClass<T>? = null) : Component {

private val type = type ?: (javaClass.genericSuperclass as? ParameterizedType)
?.let { type ->
type.actualTypeArguments
.find { t -> t is Class<*> && UniqueComponent::class.java.isAssignableFrom(t) }
?.let { it as Class<*> }
}?.kotlin ?: throw RuntimeException("Unable to find component type.")

override fun equals(other: Any?) =
this === other || type.safeCast(other) !== null
Expand Down

0 comments on commit c9a7a6e

Please sign in to comment.